premier commit
[bazdig.git] / test / simpletest / invoker.php
blob9c6ec46e75752e97fa66da6139791c43054097ce
1 <?php
2 /**
3 * Base include file for SimpleTest
4 * @package SimpleTest
5 * @subpackage UnitTester
6 * @version $Id: invoker.php,v 1.3 2006/02/06 06:13:43 lastcraft Exp $
7 */
9 /**#@+
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__) . '/');
21 /**#@-*/
23 /**
24 * This is called by the class runner to run a
25 * single test method. Will also run the setUp()
26 * and tearDown() methods.
27 * @package SimpleTest
28 * @subpackage UnitTester
30 class SimpleInvoker {
31 var $_test_case;
33 /**
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;
41 /**
42 * Accessor for test case being run.
43 * @return SimpleTestCase Test case.
44 * @access public
46 function &getTestCase() {
47 return $this->_test_case;
50 /**
51 * Runs test level set up. Used for changing
52 * the mechanics of base test cases.
53 * @param string $method Test method to call.
54 * @access public
56 function before($method) {
57 $this->_test_case->before($method);
60 /**
61 * Invokes a test method and buffered with setUp()
62 * and tearDown() calls.
63 * @param string $method Test method to call.
64 * @access public
66 function invoke($method) {
67 $this->_test_case->setUp();
68 $this->_test_case->$method();
69 $this->_test_case->tearDown();
72 /**
73 * Runs test level clean up. Used for changing
74 * the mechanics of base test cases.
75 * @param string $method Test method to call.
76 * @access public
78 function after($method) {
79 $this->_test_case->after($method);
83 /**
84 * Do nothing decorator. Just passes the invocation
85 * straight through.
86 * @package SimpleTest
87 * @subpackage UnitTester
89 class SimpleInvokerDecorator {
90 var $_invoker;
92 /**
93 * Stores the invoker to wrap.
94 * @param SimpleInvoker $invoker Test method runner.
96 function SimpleInvokerDecorator(&$invoker) {
97 $this->_invoker = &$invoker;
101 * Accessor for test case being run.
102 * @return SimpleTestCase Test case.
103 * @access public
105 function &getTestCase() {
106 return $this->_invoker->getTestCase();
110 * Runs test level set up. Used for changing
111 * the mechanics of base test cases.
112 * @param string $method Test method to call.
113 * @access public
115 function before($method) {
116 $this->_invoker->before($method);
120 * Invokes a test method and buffered with setUp()
121 * and tearDown() calls.
122 * @param string $method Test method to call.
123 * @access public
125 function invoke($method) {
126 $this->_invoker->invoke($method);
130 * Runs test level clean up. Used for changing
131 * the mechanics of base test cases.
132 * @param string $method Test method to call.
133 * @access public
135 function after($method) {
136 $this->_invoker->after($method);