本文整理汇总了PHP中junit_get_timer函数的典型用法代码示例。如果您正苦于以下问题:PHP junit_get_timer函数的具体用法?PHP junit_get_timer怎么用?PHP junit_get_timer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了junit_get_timer函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: junit_mark_test_as
/**
* @param array|string $type
* @param string $file_name
* @param string $test_name
* @param int|string $time
* @param string $message
* @param string $details
* @return void
*/
function junit_mark_test_as($type, $file_name, $test_name, $time = null, $message = '', $details = '')
{
global $JUNIT;
if (!junit_enabled()) {
return;
}
$suite = junit_get_suitename_for($file_name);
junit_suite_record($suite, 'test_total');
$time = null !== $time ? $time : junit_get_timer($file_name);
junit_suite_record($suite, 'execution_time', $time);
$escaped_details = htmlspecialchars($details, ENT_QUOTES, 'UTF-8');
$escaped_details = preg_replace_callback('/[\\0-\\x08\\x0B\\x0C\\x0E-\\x1F]/', function ($c) {
return sprintf('[[0x%02x]]', ord($c[0]));
}, $escaped_details);
$escaped_message = htmlspecialchars($message, ENT_QUOTES, 'UTF-8');
$escaped_test_name = basename($file_name) . ' - ' . htmlspecialchars($test_name, ENT_QUOTES);
$JUNIT['files'][$file_name]['xml'] = "<testcase classname='{$suite}' name='{$escaped_test_name}' time='{$time}'>\n";
if (is_array($type)) {
$output_type = $type[0] . 'ED';
$temp = array_intersect(array('XFAIL', 'FAIL', 'WARN'), $type);
$type = reset($temp);
} else {
$output_type = $type . 'ED';
}
if ('PASS' == $type || 'XFAIL' == $type) {
junit_suite_record($suite, 'test_pass');
} elseif ('BORK' == $type) {
junit_suite_record($suite, 'test_error');
$JUNIT['files'][$file_name]['xml'] .= "<error type='{$output_type}' message='{$escaped_message}'/>\n";
} elseif ('SKIP' == $type) {
junit_suite_record($suite, 'test_skip');
$JUNIT['files'][$file_name]['xml'] .= "<skipped>{$escaped_message}</skipped>\n";
} elseif ('WARN' == $type) {
junit_suite_record($suite, 'test_warn');
$JUNIT['files'][$file_name]['xml'] .= "<warning>{$escaped_message}</warning>\n";
} elseif ('FAIL' == $type) {
junit_suite_record($suite, 'test_fail');
$JUNIT['files'][$file_name]['xml'] .= "<failure type='{$output_type}' message='{$escaped_message}'>{$escaped_details}</failure>\n";
} else {
junit_suite_record($suite, 'test_error');
$JUNIT['files'][$file_name]['xml'] .= "<error type='{$output_type}' message='{$escaped_message}'>{$escaped_details}</error>\n";
}
$JUNIT['files'][$file_name]['xml'] .= "</testcase>\n";
}
示例2: junit_mark_test_as
/**
* @param array|string $type
* @param string $file_name
* @param string $test_name
* @param int|string $time
* @param string $message
* @param string $details
* @return void
*/
function junit_mark_test_as($type, $file_name, $test_name, $time = null, $message = '', $details = '')
{
global $JUNIT;
if (!junit_enabled()) {
return;
}
$suite = junit_get_suitename_for($file_name);
junit_suite_record($suite, 'test_total');
$time = null !== $time ? $time : junit_get_timer($file_name);
junit_suite_record($suite, 'execution_time', $time);
$escaped_test_name = basename($file_name) . ' - ' . htmlspecialchars($test_name, ENT_QUOTES);
$JUNIT['files'][$file_name]['xml'] = "<testcase classname='{$suite}' name='{$escaped_test_name}' time='{$time}'>\n";
if (is_array($type)) {
$output_type = $type[0] . 'ED';
$type = reset(array_intersect(array('XFAIL', 'FAIL'), $type));
} else {
$output_type = $type . 'ED';
}
if ('PASS' == $type || 'XFAIL' == $type) {
junit_suite_record($suite, 'test_pass');
} elseif ('BORK' == $type) {
junit_suite_record($suite, 'test_error');
$JUNIT['files'][$file_name]['xml'] .= "<error type='{$output_type}' message='{$message}'/>\n";
} elseif ('SKIP' == $type) {
junit_suite_record($suite, 'test_skip');
$JUNIT['files'][$file_name]['xml'] .= "<skipped>{$message}</skipped>\n";
} elseif ('FAIL' == $type) {
junit_suite_record($suite, 'test_fail');
$JUNIT['files'][$file_name]['xml'] .= "<failure type='{$output_type}' message='{$message}'>{$details}</failure>\n";
} else {
junit_suite_record($suite, 'test_error');
$JUNIT['files'][$file_name]['xml'] .= "<error type='{$output_type}' message='{$message}'>{$details}</error>\n";
}
$JUNIT['files'][$file_name]['xml'] .= "</testcase>\n";
}