1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
<? defined("SYSPATH") or die("No direct script access."); ?>
<?php
foreach ($results as $class => $methods) {
echo str_repeat("-", 100), "\n";
echo $class, "\n";
echo str_repeat("-", 100), "\n";
foreach (array("score", "total", "passed", "failed", "errors") as $key) {
@$totals[$key] += $stats[$class][$key];
}
if (empty($methods)) {
echo Kohana::lang("unit_test.no_tests_found"), "\n";
} else {
foreach ($methods as $method => $result) {
// Hide passed tests from report
if ($result === true AND $hide_passed === true) {
continue;
}
printf("%-56.56s", $method);
if ($result === true) {
echo Kohana::lang("unit_test.passed"), "\n";
} else if ($result instanceof Kohana_Unit_Test_Exception) {
echo Kohana::lang("unit_test.failed"), "\n";
echo " ", $result->getMessage(), "\n";
echo " ", $result->getFile();
echo " ", "(" . Kohana::lang("unit_test.line") . " " . $result->getLine(), ")\n";
if ($result->getDebug() !== null) {
echo " ", "(", gettype($result->getDebug()), ") ",
var_export($result->getDebug(), true), "\n";
}
echo "\n";
} else if ($result instanceof Exception) {
echo Kohana::lang("unit_test.error"), "\n";
if ($result->getMessage()) {
echo " ", $result->getMessage(), "\n";
}
echo " ", $result->getFile(), " (",
Kohana::lang("unit_test.line"), " ", $result->getLine(), ")\n";
echo "\n";
}
}
}
echo str_repeat("=", 100), "\n";
printf(">> %s\t%s: %.2f%%\t%s: %d\t%s: %d\t%s: %d\t%s: %d\n",
$class,
Kohana::lang("unit_test.score"), $stats[$class]["score"],
Kohana::lang("unit_test.total"), $stats[$class]["total"],
Kohana::lang("unit_test.passed"), $stats[$class]["passed"],
Kohana::lang("unit_test.failed"), $stats[$class]["failed"],
Kohana::lang("unit_test.errors"), $stats[$class]["errors"]);
echo str_repeat("-", 100), "\n\n\n";
}
printf(">> TOTAL\t%s: %.2f%%\t%s: %d\t%s: %d\t%s: %d\t%s: %d\n",
Kohana::lang("unit_test.score"),
($totals["total"] ? 100 * ($totals["passed"] / $totals["total"]) : 0),
Kohana::lang("unit_test.total"), $totals["total"],
Kohana::lang("unit_test.passed"), $totals["passed"],
Kohana::lang("unit_test.failed"), $totals["failed"],
Kohana::lang("unit_test.errors"), $totals["errors"]);
|