3 // +------------------------------------------------------------------------+
5 // +------------------------------------------------------------------------+
6 // | Copyright (c) 2002-2003 Sebastian Bergmann <sb@sebastian-bergmann.de>. |
7 // +------------------------------------------------------------------------+
8 // | This source file is subject to version 3.00 of the PHP License, |
9 // | that is available at http://www.php.net/license/3_0.txt. |
10 // | If you did not receive a copy of the PHP license and are unable to |
11 // | obtain it through the world-wide-web, please send a note to |
12 // | license@php.net so we can mail you a copy immediately. |
13 // +------------------------------------------------------------------------+
15 // $Id: TestDecorator.php,v 1.10 2004/10/01 06:11:39 sebastian Exp $
18 require_once 'PHPUnit/TestCase.php';
19 require_once 'PHPUnit/TestSuite.php';
22 * A Decorator for Tests.
24 * Use TestDecorator as the base class for defining new
25 * test decorators. Test decorator subclasses can be introduced
26 * to add behaviour before or after a test is run.
28 * @author Sebastian Bergmann <sb@sebastian-bergmann.de>
29 * @copyright Copyright © 2002-2004 Sebastian Bergmann <sb@sebastian-bergmann.de>
30 * @license http://www.php.net/license/3_0.txt The PHP License, Version 3.0
34 class PHPUnit_TestDecorator
{
36 * The Test to be decorated.
49 function PHPUnit_TestDecorator(&$test) {
50 if (is_object($test) &&
51 (is_a($test, 'PHPUnit_TestCase') ||
52 is_a($test, 'PHPUnit_TestSuite'))) {
59 * Runs the test and collects the
60 * result in a TestResult.
65 function basicRun(&$result) {
66 $this->_test
->run($result);
70 * Counts the number of test cases that
71 * will be run by this test.
76 function countTestCases() {
77 return $this->_test
->countTestCases();
81 * Returns the test to be run.
91 * Runs the decorated test and collects the
92 * result in a TestResult.
98 function run(&$result) { /* abstract */ }
101 * Returns a string representation of the test.
106 function toString() {
107 return $this->_test
->toString();