4
* Provides a nice HTML output for PHPUnit suite tests.
6
* @version $Id: HTML_TestListener.php,v 1.1 2004/03/19 00:48:39 cellog Exp $
7
* @author Laurent Laville <pear@laurent-laville.org>
11
class HTML_TestListener extends PHPUnit_TestListener {
13
function HTML_TestListener() {
16
<table cellspacing="1" cellpadding="1" border="0" width="90%" align="center" class="details">
17
<tr><th>Class</th><th>Function</th><th>Success</th><th>Meta-result</th></tr>
22
function addError(&$test, &$t) {
26
function addFailure(&$test, &$t) {
30
function endTest(&$test) {
31
/* Report both the test result and, for this special situation
32
where some tests are expected to fail, a "meta" test result
33
which indicates whether the test result matches the
36
$expect_failure = preg_match('/fail/i', $test->getName());
37
$test_passed = ($this->_fails == 0 && $this->_errors == 0);
39
if ($this->_errors > 0) {
40
$outcome = "<span class=\"Error\">ERROR</span>";
41
} else if ($this->_fails > 0) {
42
$outcome = "<span class=\"Failure\">FAIL</span>";
44
$outcome = "<span class=\"Pass\">OK</span>";
46
if ($this->_errors > 0) {
47
$meta_outcome = '<span class="Unknown">unknown</span>';
49
$meta_outcome = ($expect_failure xor $test_passed)
50
? '<span class="Expected">as expected</span>'
51
: '<span class="Unexpected">UNEXPECTED</span>';
53
printf("<td>$outcome</td><td>$meta_outcome</td></tr>");
56
function startTest(&$test) {
59
printf("<tr><td>%s </td><td>%s </td>", get_class($test), $test->getName());
b'\\ No newline at end of file'