protected static function report_text(array $tests)
{
$total_assert_counts = static::assertion_stats($tests);
$test_counts = static::test_stats($tests);
static::report_out("RESULTS:");
static::report_out("--------------------------------------------");
foreach ($tests as $name => $tdata) {
$assert_counts = static::assertion_stats($tests, $name);
if ($tdata['pass']) {
$test_color = 'GREEN';
} else {
if ($assert_counts['total'] - $assert_counts['expected_fail'] == $assert_counts['pass']) {
$test_color = 'YELLOW';
} else {
$test_color = 'RED';
}
}
static::report_out("TEST:" . static::color(" {$name} ({$assert_counts['pass']}/{$assert_counts['total']}):", $test_color));
foreach ($tdata['assertions'] as $ass) {
if ($ass['expected_fail']) {
$assert_color = 'YELLOW';
} else {
$assert_color = $ass['result'] == static::PASS ? 'GREEN' : 'RED';
}
$file_line = "{$ass['file']}#{$ass['line']}";
$args_str = '';
if ($ass['result'] === static::FAIL) {
$args_str = implode(', ', $ass['args_strs']);
}
$ass_str = "{$ass['result']} {$ass['func_name']}({$args_str}) {$ass['msg']}";
$ass_str .= $ass['expected_fail'] ? '(expected)' : '';
if ($ass['result'] === static::FAIL) {
$ass_str .= PHP_EOL . " {$ass['fail_info']}";
$ass_str .= PHP_EOL . " {$file_line}";
}
static::report_out(" * " . static::color($ass_str, $assert_color));
}
if (count($tdata['errors']) > 0) {
$bt = '';
foreach ($tdata['errors'] as $error) {
$sep = "\n -> ";
$bt = $sep . implode($sep, $error['backtrace']);
static::report_out(' * ' . static::color(strtoupper($error['type']) . ": {$error['msg']} in {$bt}", 'RED'));
}
}
static::report_out("");
}
$err_color = $test_counts['error'] > 0 ? 'RED' : 'WHITE';
static::report_out("ERRORS/EXCEPTIONS: " . static::color($test_counts['error'], $err_color));
static::report_out("ASSERTIONS: " . static::color("{$total_assert_counts['pass']} pass", 'GREEN') . ", " . static::color("{$total_assert_counts['fail']} fail", 'RED') . ", " . static::color("{$total_assert_counts['expected_fail']} expected fail", 'YELLOW') . ", " . static::color("{$total_assert_counts['total']} total", 'WHITE'));
static::report_out("TESTS: {$test_counts['run']} run, " . static::color("{$test_counts['pass']} pass", 'GREEN') . ", " . static::color("{$test_counts['total']} total", 'WHITE'));
}