[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/tests_runner/lib/simpletest/ -> invoker.php (source)

   1  <?php
   2      /**

   3       *    Base include file for SimpleTest

   4       *    @package    SimpleTest

   5       *    @subpackage    UnitTester

   6       *    @version    $Id: invoker.php 5999 2007-06-18 13:13:08Z pachanga $

   7       */
   8  
   9      /**#@+

  10       * Includes SimpleTest files and defined the root constant

  11       * for dependent libraries.

  12       */
  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__) . '/');
  20      }
  21      /**#@-*/

  22  
  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

  29       */
  30      class SimpleInvoker {
  31          var $_test_case;
  32  
  33          /**

  34           *    Stashes the test case for later.

  35           *    @param SimpleTestCase $test_case  Test case to run.

  36           */
  37          function SimpleInvoker(&$test_case) {
  38              $this->_test_case = &$test_case;
  39          }
  40  
  41          /**

  42           *    Accessor for test case being run.

  43           *    @return SimpleTestCase    Test case.

  44           *    @access public

  45           */
  46          function &getTestCase() {
  47              return $this->_test_case;
  48          }
  49  
  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

  55           */
  56          function before($method) {
  57              $this->_test_case->before($method);
  58          }
  59  
  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

  65           */
  66          function invoke($method) {
  67              $this->_test_case->setUp();
  68              $this->_test_case->$method();
  69              $this->_test_case->tearDown();
  70          }
  71  
  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

  77           */
  78          function after($method) {
  79              $this->_test_case->after($method);
  80          }
  81      }
  82  
  83      /**

  84       *    Do nothing decorator. Just passes the invocation

  85       *    straight through.

  86       *      @package SimpleTest

  87       *      @subpackage UnitTester

  88       */
  89      class SimpleInvokerDecorator {
  90          var $_invoker;
  91  
  92          /**

  93           *    Stores the invoker to wrap.

  94           *    @param SimpleInvoker $invoker  Test method runner.

  95           */
  96          function SimpleInvokerDecorator(&$invoker) {
  97              $this->_invoker = &$invoker;
  98          }
  99  
 100          /**

 101           *    Accessor for test case being run.

 102           *    @return SimpleTestCase    Test case.

 103           *    @access public

 104           */
 105          function &getTestCase() {
 106              return $this->_invoker->getTestCase();
 107          }
 108  
 109          /**

 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

 114           */
 115          function before($method) {
 116              $this->_invoker->before($method);
 117          }
 118  
 119          /**

 120           *    Invokes a test method and buffered with setUp()

 121           *    and tearDown() calls.

 122           *    @param string $method    Test method to call.

 123           *    @access public

 124           */
 125          function invoke($method) {
 126              $this->_invoker->invoke($method);
 127          }
 128  
 129          /**

 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

 134           */
 135          function after($method) {
 136              $this->_invoker->after($method);
 137          }
 138      }
 139  ?>


Generated: Sat Nov 22 03:48:54 2008 Cross-referenced by PHPXref 0.7