3 * This file is part of PHPUnit.
5 * (c) Sebastian Bergmann <sebastian@phpunit.de>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
12 * A Decorator for Tests.
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.
18 * @since Class available since Release 2.0.0
20 class PHPUnit_Extensions_TestDecorator extends PHPUnit_Framework_Assert implements PHPUnit_Framework_Test, PHPUnit_Framework_SelfDescribing
23 * The Test to be decorated.
27 protected $test = null;
32 * @param PHPUnit_Framework_Test $test
34 public function __construct(PHPUnit_Framework_Test $test)
40 * Returns a string representation of the test.
44 public function toString()
46 return $this->test->toString();
50 * Runs the test and collects the
51 * result in a TestResult.
53 * @param PHPUnit_Framework_TestResult $result
55 public function basicRun(PHPUnit_Framework_TestResult $result)
57 $this->test->run($result);
61 * Counts the number of test cases that
62 * will be run by this test.
66 public function count()
68 return count($this->test);
72 * Creates a default TestResult object.
74 * @return PHPUnit_Framework_TestResult
76 protected function createResult()
78 return new PHPUnit_Framework_TestResult;
82 * Returns the test to be run.
84 * @return PHPUnit_Framework_Test
86 public function getTest()
92 * Runs the decorated test and collects the
93 * result in a TestResult.
95 * @param PHPUnit_Framework_TestResult $result
97 * @return PHPUnit_Framework_TestResult
99 public function run(PHPUnit_Framework_TestResult $result = null)
101 if ($result === null) {
102 $result = $this->createResult();
105 $this->basicRun($result);