Smutty

MVC Framework

View Code: Smutty_Test_Reporter

Browse: All · Classes · Plugins

1
<?php
2
3
/**
4
* handles the reporting of messages from user test cases
5
*
6
*/
7
9
10
/** results */
11
private $html = '';
12
13
/**
14
* a test has failed
15
*
16
* @param String $message the error message
17
* @return nothing
18
*
19
*/
20
21
function paintFail($message) {
22
23
parent::paintFail($message);
24
25
$breadcrumb = $this->getTestList();
26
array_shift($breadcrumb);
27
28
$this->html = "<span class=\"fail\">Fail</span>: " .
29
implode(" -&gt; ", $breadcrumb) .
30
" -&gt; " . $message . "<br />\n";
31
32
}
33
34
/**
35
* an exception was raised
36
*
37
* @param String $message the message
38
* @return nothing
39
*
40
*/
41
42
function paintError( $message ) {
43
44
parent::paintError($message);
45
46
$breadcrumb = $this->getTestList();
47
array_shift($breadcrumb);
48
49
$this->html .= "<div><span class=\"fail\">Exception</span>: " .
50
implode(" -&gt; ", $breadcrumb) .
51
" -&gt; <strong>" . $message . "</strong></div>\n";
52
53
}
54
55
/**
56
* the footer with the test results
57
*
58
* @param String $test_name name of the test
59
* @return nothing
60
*
61
*/
62
63
function paintFooter( $test_name ) {
64
65
$colour = ($this->getFailCount() + $this->getExceptionCount() > 0 ? "red" : "green");
66
$this->html .= "<div style=\"" .
67
"padding: 8px; margin-top: 1em; background-color: $colour; color: white;" .
68
"\">" .
69
$this->getTestCaseProgress() . "/" . $this->getTestCaseCount() .
70
" test cases complete:\n" .
71
"<strong>" . $this->getPassCount() . "</strong> passes, " .
72
"<strong>" . $this->getFailCount() . "</strong> fails and " .
73
"<strong>" . $this->getExceptionCount() . "</strong> exceptions." .
74
"</div>\n" .
75
"</body>\n</html>\n";
76
77
}
78
79
/**
80
* returns the results after the tests have been run
81
*
82
* @return String the test results
83
*
84
*/
85
86
function getResults() {
87
return $this->html;
88
}
89
90
}
91
92
?>

The code shown here is the code that is currently running this site. If you want to view the latest SVN version of the code then go to the Subversion repository.