-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextend_simpleunittest.php
87 lines (73 loc) · 2.66 KB
/
extend_simpleunittest.php
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
namespace SimpleUnitTest;
class Test extends Unit_Test
{
/*
If you need to add a curl option do it here.
Note: This method is an abstract method from the parent class
so it needs to be implemented at least trivially
*/
protected function __init(){
//self::$CURL_OPTIONS[CURLOPT_TIMEOUT]=30;
}
public function print_results(){
$html='<table class="simple_test_result" >
<tr style="height:4em;"><td colspan="8"><b>Class: </b>'. $this->meta['Class'] . '
<br/>Parameters: ' . $this->meta['Parameters'] . '<br/>';
foreach($this->result as $result){
if(count($result['Errors'])){
$html.='<tr><td colspan="8"><b>Error</b></td></tr>';
foreach($result['Errors'] as $error){
$html.='<tr><td colspan="8">';
foreach($error as $k=>$v){
$html.=$k . ': '. $v . '<br/>';
}
$html.='</td></tr>';
}
}
if(isset($result['Method']) && isset($result['Tests'])){
$html.='<tr style="height:3em;"><td colspan="8"><b>Method: </b>' .$result['Method'] . '
<b>Number of tests: </b>'. count($result['Tests']) . '</td></tr>';
if(isset($result['Tests']) && count($result['Tests'])){
$html.='<tr><th>Test</th><th>Status</th><th>Result</th><th>Expected Value</th><th>Parameters</th><th>Elapsed time</th><th>MB</th><th style="width:30%;">Exceptions/Warnings</th></tr>';
foreach($result['Tests'] as $tn=>$data){
$class='class="warning"';
if($data['Status']=='Passed'){
$class='class="passed"';
}
elseif($data['Status']=='Failed'){
$class='class="fail"';
}
if(is_array($data['Expected Value'])|| is_object($data['Expected Value'])){
$data['Expected Value']=var_export($data['Expected Value'],true);
}
if(is_array($data['Result'])|| is_object($data['Result'])){
$data['Result']=var_export($data['Result'], true);
}
$html.='<tr '. $class . '>
<td>'. $tn .'</td>
<td>' . $data['Status'] .' </td>
<td>' . $data['Result'] . '</td>
<td>' . $data['Expected Value'] . '</td>
<td>' . implode('<br/>', $data['Parameters']) . '</td>
<td>' . $data['Elapsed Time'] . '</td>
<td>' . $data['Memory Usage'] . '</td>
<td>' . $data['Exception'] . ' ' . $data['Warnings'] . '</td>
</tr>';
}
}
if(isset($result['SpyLog'])){
$html.='<tr style="height:2.5em;"><td colspan="8"><b>Spies</b></td></tr>';
foreach($result['SpyLog'] as $class=>$dataset){
foreach($dataset as $spy=>$data){
$html.="<tr><td><b>[{$class}] {$spy}</b></td><td colspan=\"7\">". implode('<br/>', $data) ."</td></tr>";
}
}
}
}
}
$html.='</table>';
return $html;
}
}
?>