3 * Base include file for SimpleTest
5 * @subpackage UnitTester
10 * Includes SimpleTest files and defined the root constant
11 * for dependent libraries.
13 require_once(dirname(__FILE__
) . '/errors.php');
14 require_once(dirname(__FILE__
) . '/compatibility.php');
15 require_once(dirname(__FILE__
) . '/scorer.php');
16 require_once(dirname(__FILE__
) . '/expectation.php');
17 require_once(dirname(__FILE__
) . '/dumper.php');
18 if (! defined('SIMPLE_TEST')) {
19 define('SIMPLE_TEST', dirname(__FILE__
) . '/');
24 * This is called by the class runner to run a
25 * single test method. Will also run the setUp()
26 * and tearDown() methods.
28 * @subpackage UnitTester
34 * Stashes the test case for later.
35 * @param SimpleTestCase $test_case Test case to run.
37 function SimpleInvoker(&$test_case) {
38 $this->_test_case
= &$test_case;
42 * Accessor for test case being run.
43 * @return SimpleTestCase Test case.
46 function &getTestCase() {
47 return $this->_test_case
;
51 * Runs test level set up. Used for changing
52 * the mechanics of base test cases.
53 * @param string $method Test method to call.
56 function before($method) {
57 $this->_test_case
->before($method);
61 * Invokes a test method and buffered with setUp()
62 * and tearDown() calls.
63 * @param string $method Test method to call.
66 function invoke($method) {
67 $this->_test_case
->setUp();
69 // note: this breaks PHP4 compatibility!
72 $this->_test_case
->$method();
73 } catch (Exception
$e) {
76 $this->_test_case
->tearDown();
84 * Runs test level clean up. Used for changing
85 * the mechanics of base test cases.
86 * @param string $method Test method to call.
89 function after($method) {
90 $this->_test_case
->after($method);
95 * Do nothing decorator. Just passes the invocation
98 * @subpackage UnitTester
100 class SimpleInvokerDecorator
{
104 * Stores the invoker to wrap.
105 * @param SimpleInvoker $invoker Test method runner.
107 function SimpleInvokerDecorator(&$invoker) {
108 $this->_invoker
= &$invoker;
112 * Accessor for test case being run.
113 * @return SimpleTestCase Test case.
116 function &getTestCase() {
117 return $this->_invoker
->getTestCase();
121 * Runs test level set up. Used for changing
122 * the mechanics of base test cases.
123 * @param string $method Test method to call.
126 function before($method) {
127 $this->_invoker
->before($method);
131 * Invokes a test method and buffered with setUp()
132 * and tearDown() calls.
133 * @param string $method Test method to call.
136 function invoke($method) {
137 $this->_invoker
->invoke($method);
141 * Runs test level clean up. Used for changing
142 * the mechanics of base test cases.
143 * @param string $method Test method to call.
146 function after($method) {
147 $this->_invoker
->after($method);