blob: a6b3ca65885782a21d61df9da1497928ab7a3596 (
plain)
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
64
|
<?php
/**
* Provides a nice HTML output for PHPUnit suite tests.
*
* @version $Id$
* @author Laurent Laville <pear@laurent-laville.org>
* @package HTML_CSS
*/
class HTML_TestListener extends PHPUnit_TestListener {
function HTML_TestListener() {
$report = <<<EOS
<table cellspacing="1" cellpadding="1" border="0" width="90%" align="center" class="details">
<tr><th>Class</th><th>Function</th><th>Success</th><th>Meta-result</th></tr>
EOS;
echo $report;
}
function addError(&$test, &$t) {
$this->_errors += 1;
}
function addFailure(&$test, &$t) {
$this->_fails += 1;
}
function endTest(&$test) {
/* Report both the test result and, for this special situation
where some tests are expected to fail, a "meta" test result
which indicates whether the test result matches the
expected result.
*/
$expect_failure = preg_match('/fail/i', $test->getName());
$test_passed = ($this->_fails == 0 && $this->_errors == 0);
if ($this->_errors > 0) {
$outcome = "<span class=\"Error\">ERROR</span>";
} else if ($this->_fails > 0) {
$outcome = "<span class=\"Failure\">FAIL</span>";
} else {
$outcome = "<span class=\"Pass\">OK</span>";
}
if ($this->_errors > 0) {
$meta_outcome = '<span class="Unknown">unknown</span>';
} else {
$meta_outcome = ($expect_failure xor $test_passed)
? '<span class="Expected">as expected</span>'
: '<span class="Unexpected">UNEXPECTED</span>';
}
printf("<td>$outcome</td><td>$meta_outcome</td></tr>");
}
function startTest(&$test) {
$this->_fails = 0;
$this->_errors = 0;
printf("<tr><td>%s </td><td>%s </td>", get_class($test), $test->getName());
}
}
?>
|