Fix bug in style changes for the Use cases on the live site.
[yaffs-website] / vendor / phpunit / phpunit / src / Extensions / TestDecorator.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  * A Decorator for Tests.
13  *
14  * Use TestDecorator as the base class for defining new
15  * test decorators. Test decorator subclasses can be introduced
16  * to add behaviour before or after a test is run.
17  *
18  * @since Class available since Release 2.0.0
19  */
20 class PHPUnit_Extensions_TestDecorator extends PHPUnit_Framework_Assert implements PHPUnit_Framework_Test, PHPUnit_Framework_SelfDescribing
21 {
22     /**
23      * The Test to be decorated.
24      *
25      * @var object
26      */
27     protected $test = null;
28
29     /**
30      * Constructor.
31      *
32      * @param PHPUnit_Framework_Test $test
33      */
34     public function __construct(PHPUnit_Framework_Test $test)
35     {
36         $this->test = $test;
37     }
38
39     /**
40      * Returns a string representation of the test.
41      *
42      * @return string
43      */
44     public function toString()
45     {
46         return $this->test->toString();
47     }
48
49     /**
50      * Runs the test and collects the
51      * result in a TestResult.
52      *
53      * @param PHPUnit_Framework_TestResult $result
54      */
55     public function basicRun(PHPUnit_Framework_TestResult $result)
56     {
57         $this->test->run($result);
58     }
59
60     /**
61      * Counts the number of test cases that
62      * will be run by this test.
63      *
64      * @return int
65      */
66     public function count()
67     {
68         return count($this->test);
69     }
70
71     /**
72      * Creates a default TestResult object.
73      *
74      * @return PHPUnit_Framework_TestResult
75      */
76     protected function createResult()
77     {
78         return new PHPUnit_Framework_TestResult;
79     }
80
81     /**
82      * Returns the test to be run.
83      *
84      * @return PHPUnit_Framework_Test
85      */
86     public function getTest()
87     {
88         return $this->test;
89     }
90
91     /**
92      * Runs the decorated test and collects the
93      * result in a TestResult.
94      *
95      * @param PHPUnit_Framework_TestResult $result
96      *
97      * @return PHPUnit_Framework_TestResult
98      */
99     public function run(PHPUnit_Framework_TestResult $result = null)
100     {
101         if ($result === null) {
102             $result = $this->createResult();
103         }
104
105         $this->basicRun($result);
106
107         return $result;
108     }
109 }