Source for file invoker.php

Documentation is available at invoker.php

  1. <?php
  2. /**
  3.  *  Base include file for SimpleTest
  4.  *  @package    SimpleTest
  5.  *  @subpackage UnitTester
  6.  *  @version    $Id: invoker.php 1722 2008-04-07 19:30:56Z lastcraft $
  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.  *    This is called by the class runner to run a
  24.  *    single test method. Will also run the setUp()
  25.  *    and tearDown() methods.
  26.  *    @package SimpleTest
  27.  *    @subpackage UnitTester
  28.  */
  29. class SimpleInvoker {
  30.     var $_test_case;
  31.  
  32.     /**
  33.      *    Stashes the test case for later.
  34.      *    @param SimpleTestCase $test_case  Test case to run.
  35.      */
  36.     function SimpleInvoker(&$test_case{
  37.         $this->_test_case = &$test_case;
  38.     }
  39.  
  40.     /**
  41.      *    Accessor for test case being run.
  42.      *    @return SimpleTestCase    Test case.
  43.      *    @access public
  44.      */
  45.     function &getTestCase({
  46.         return $this->_test_case;
  47.     }
  48.  
  49.     /**
  50.      *    Runs test level set up. Used for changing
  51.      *    the mechanics of base test cases.
  52.      *    @param string $method    Test method to call.
  53.      *    @access public
  54.      */
  55.     function before($method{
  56.         $this->_test_case->before($method);
  57.     }
  58.  
  59.     /**
  60.      *    Invokes a test method and buffered with setUp()
  61.      *    and tearDown() calls.
  62.      *    @param string $method    Test method to call.
  63.      *    @access public
  64.      */
  65.     function invoke($method{
  66.         $this->_test_case->setUp();
  67.         $this->_test_case->$method();
  68.         $this->_test_case->tearDown();
  69.     }
  70.  
  71.     /**
  72.      *    Runs test level clean up. Used for changing
  73.      *    the mechanics of base test cases.
  74.      *    @param string $method    Test method to call.
  75.      *    @access public
  76.      */
  77.     function after($method{
  78.         $this->_test_case->after($method);
  79.     }
  80. }
  81.  
  82. /**
  83.  *    Do nothing decorator. Just passes the invocation
  84.  *    straight through.
  85.  *    @package SimpleTest
  86.  *    @subpackage UnitTester
  87.  */
  88.     var $_invoker;
  89.  
  90.     /**
  91.      *    Stores the invoker to wrap.
  92.      *    @param SimpleInvoker $invoker  Test method runner.
  93.      */
  94.     function SimpleInvokerDecorator(&$invoker{
  95.         $this->_invoker = &$invoker;
  96.     }
  97.  
  98.     /**
  99.      *    Accessor for test case being run.
  100.      *    @return SimpleTestCase    Test case.
  101.      *    @access public
  102.      */
  103.     function &getTestCase({
  104.         return $this->_invoker->getTestCase();
  105.     }
  106.  
  107.     /**
  108.      *    Runs test level set up. Used for changing
  109.      *    the mechanics of base test cases.
  110.      *    @param string $method    Test method to call.
  111.      *    @access public
  112.      */
  113.     function before($method{
  114.         $this->_invoker->before($method);
  115.     }
  116.  
  117.     /**
  118.      *    Invokes a test method and buffered with setUp()
  119.      *    and tearDown() calls.
  120.      *    @param string $method    Test method to call.
  121.      *    @access public
  122.      */
  123.     function invoke($method{
  124.         $this->_invoker->invoke($method);
  125.     }
  126.  
  127.     /**
  128.      *    Runs test level clean up. Used for changing
  129.      *    the mechanics of base test cases.
  130.      *    @param string $method    Test method to call.
  131.      *    @access public
  132.      */
  133.     function after($method{
  134.         $this->_invoker->after($method);
  135.     }
  136. }
  137. ?>

Documentation generated on Sun, 04 May 2008 09:21:42 -0500 by phpDocumentor 1.3.0