Yaffs site version 1.1
[yaffs-website] / vendor / phpunit / phpunit / tests / Framework / TestListenerTest.php
1 <?php
2 /*
3  * This file is part of PHPUnit.
4  *
5  * (c) Sebastian Bergmann <sebastian@phpunit.de>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 /**
12  * @since      Class available since Release 2.0.0
13  * @covers     PHPUnit_Framework_TestCase
14  */
15 class Framework_TestListenerTest extends PHPUnit_Framework_TestCase implements PHPUnit_Framework_TestListener
16 {
17     protected $endCount;
18     protected $errorCount;
19     protected $failureCount;
20     protected $notImplementedCount;
21     protected $riskyCount;
22     protected $skippedCount;
23     protected $result;
24     protected $startCount;
25
26     public function addError(PHPUnit_Framework_Test $test, Exception $e, $time)
27     {
28         $this->errorCount++;
29     }
30
31     public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
32     {
33         $this->failureCount++;
34     }
35
36     public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time)
37     {
38         $this->notImplementedCount++;
39     }
40
41     public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time)
42     {
43         $this->riskyCount++;
44     }
45
46     public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time)
47     {
48         $this->skippedCount++;
49     }
50
51     public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
52     {
53     }
54
55     public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
56     {
57     }
58
59     public function startTest(PHPUnit_Framework_Test $test)
60     {
61         $this->startCount++;
62     }
63
64     public function endTest(PHPUnit_Framework_Test $test, $time)
65     {
66         $this->endCount++;
67     }
68
69     protected function setUp()
70     {
71         $this->result = new PHPUnit_Framework_TestResult;
72         $this->result->addListener($this);
73
74         $this->endCount            = 0;
75         $this->failureCount        = 0;
76         $this->notImplementedCount = 0;
77         $this->riskyCount          = 0;
78         $this->skippedCount        = 0;
79         $this->startCount          = 0;
80     }
81
82     public function testError()
83     {
84         $test = new TestError;
85         $test->run($this->result);
86
87         $this->assertEquals(1, $this->errorCount);
88         $this->assertEquals(1, $this->endCount);
89     }
90
91     public function testFailure()
92     {
93         $test = new Failure;
94         $test->run($this->result);
95
96         $this->assertEquals(1, $this->failureCount);
97         $this->assertEquals(1, $this->endCount);
98     }
99
100     public function testStartStop()
101     {
102         $test = new Success;
103         $test->run($this->result);
104
105         $this->assertEquals(1, $this->startCount);
106         $this->assertEquals(1, $this->endCount);
107     }
108 }