OSDN Git Service

089c46e1f29cb8f3dff1e172a3120fb324f374d0
[ethna/ethna.git] / test / TextDetailReporter.php
1 <?php
2 /**
3  * TextDetailReporter.php
4  *
5  */
6
7 /**
8  * TextDetailReporter
9  *
10  */
11 class TextDetailReporter extends SimpleReporter {
12
13     /**
14      *    Does nothing yet. The first output will
15      *    be sent on the first test start.
16      *    @access public
17      */
18     function TextDetailReporter()
19     {
20         $this->SimpleReporter();
21     }
22
23     /**
24      *    Paints the title only.
25      *    @param string $test_name        Name class of test.
26      *    @access public
27      */
28     function paintHeader($test_name) {
29         if (!SimpleReporter::inCli()) {
30             header('Content-type: text/plain');
31         }
32         print "{$test_name}\n";
33         flush();
34     }
35
36     /**
37      *    Paints the end of the test with a summary of
38      *    the passes and failures.
39      *    @param string $test_name        Name class of test.
40      *    @access public
41      */
42     function paintFooter($test_name) {
43         if ($this->getFailCount() + $this->getExceptionCount() == 0) {
44             print "\nAll OK\n";
45         } else {
46             print "\nFAILURES!!!\n";
47         }
48         print "Test cases run: " . $this->getTestCaseProgress() .
49             "/" . $this->getTestCaseCount() .
50             ", Passes: " . $this->getPassCount() .
51             ", Failures: " . $this->getFailCount() .
52             ", Exceptions: " . $this->getExceptionCount() . "\n";
53     }
54
55     /**
56      *    Paints the test failure as a stack trace.
57      *    @param string $message    Failure message displayed in
58      *                              the context of the other tests.
59      *    @access public
60      */
61     function paintFail($message) {
62         parent::paintFail($message);
63         print "\n\t" . $this->getFailCount() . ") $message\n";
64         $breadcrumb = $this->getTestList();
65         array_shift($breadcrumb);
66         print "\tin " . implode("\n\tin ", array_reverse($breadcrumb));
67         print "\n";
68     }
69
70     /**
71      *    Paints a PHP error or exception.
72      *    @param string $message        Message is ignored.
73      *    @access public
74      *    @abstract
75      */
76     function paintError($message) {
77         parent::paintError($message);
78         print "Exception " . $this->getExceptionCount() . "!\n$message\n";
79     }
80
81     /**
82      *    Paints formatted text such as dumped variables.
83      *    @param string $message        Text to show.
84      *    @access public
85      */
86     function paintFormattedMessage($message) {
87         print "$message\n";
88         flush();
89     }
90
91     function paintMethodStart($test_name)
92     {
93         //print "Start {$test_name} Test\n";
94         print "  |--- {$test_name}";
95         $this->before_fails = $this->_fails;
96     }
97
98     var $before_fails = 0;
99     
100     function paintMethodEnd($test_name)
101     {
102         //print "End {$test_name} Test\n";
103         if ($this->before_fails != $this->_fails) {
104             print " - NG";
105         } else {
106             print " - OK";
107         }
108         print "\n";
109     }
110
111     function paintCaseStart($test_name)
112     {
113         print "\n {$test_name}\n";
114         return parent::paintCaseStart($test_name);
115     }
116 }
117 ?>