- added INSTALL file
[plcapi.git] / test / PHPUnit / TestDecorator.php
1 <?php
2 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
3
4 /**
5  * PHP Version 4
6  *
7  * LICENSE: This source file is subject to version 3.0 of the PHP license
8  * that is available through the world-wide-web at the following URI:
9  * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
10  * the PHP License and are unable to obtain it through the web, please
11  * send a note to license@php.net so we can mail you a copy immediately.
12  *
13  * @category   Testing
14  * @package    PHPUnit
15  * @author     Sebastian Bergmann <sb@sebastian-bergmann.de>
16  * @copyright  2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de>
17  * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
18  * @version    CVS: $Id$
19  * @link       http://pear.php.net/package/PHPUnit
20  * @since      File available since Release 1.0.0
21  */
22
23 require_once 'PHPUnit/TestCase.php';
24 require_once 'PHPUnit/TestSuite.php';
25
26 if (!function_exists('is_a')) {
27     require_once 'PHP/Compat/Function/is_a.php';
28 }
29
30 /**
31  * A Decorator for Tests.
32  *
33  * Use TestDecorator as the base class for defining new
34  * test decorators. Test decorator subclasses can be introduced
35  * to add behaviour before or after a test is run.
36  *
37  * @category   Testing
38  * @package    PHPUnit
39  * @author     Sebastian Bergmann <sb@sebastian-bergmann.de>
40  * @copyright  2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de>
41  * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
42  * @version    Release: @package_version@
43  * @link       http://pear.php.net/package/PHPUnit
44  * @since      Class available since Release 1.0.0
45  */
46 class PHPUnit_TestDecorator {
47     /**
48      * The Test to be decorated.
49      *
50      * @var    object
51      * @access protected
52      */
53     var $_test = NULL;
54
55     /**
56      * Constructor.
57      *
58      * @param  object
59      * @access public
60      */
61     function PHPUnit_TestDecorator(&$test) {
62         if (is_object($test) &&
63             (is_a($test, 'PHPUnit_TestCase') ||
64              is_a($test, 'PHPUnit_TestSuite'))) {
65
66             $this->_test = &$test;
67         }
68     }
69
70     /**
71      * Runs the test and collects the
72      * result in a TestResult.
73      *
74      * @param  object
75      * @access public
76      */
77     function basicRun(&$result) {
78         $this->_test->run($result);
79     }
80
81     /**
82      * Counts the number of test cases that
83      * will be run by this test.
84      *
85      * @return integer
86      * @access public
87      */
88     function countTestCases() {
89         return $this->_test->countTestCases();
90     }
91
92     /**
93      * Returns the test to be run.
94      *
95      * @return object
96      * @access public
97      */
98     function &getTest() {
99         return $this->_test;
100     }
101
102     /**
103      * Runs the decorated test and collects the
104      * result in a TestResult.
105      *
106      * @param  object
107      * @access public
108      * @abstract
109      */
110     function run(&$result) { /* abstract */ }
111
112     /**
113      * Returns a string representation of the test.
114      *
115      * @return string
116      * @access public
117      */
118     function toString() {
119         return $this->_test->toString();
120     }
121 }
122
123 /*
124  * Local variables:
125  * tab-width: 4
126  * c-basic-offset: 4
127  * c-hanging-comment-ender-p: nil
128  * End:
129  */
130 ?>