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 1785 2008-04-26 13:56:41Z pp11 $
  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.     private $test_case;
  32.  
  33.     /**
  34.      *    Stashes the test case for later.
  35.      *    @param SimpleTestCase $test_case  Test case to run.
  36.      */
  37.     function __construct($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.     private $invoker;
  90.  
  91.     /**
  92.      *    Stores the invoker to wrap.
  93.      *    @param SimpleInvoker $invoker  Test method runner.
  94.      */
  95.     function __construct($invoker{
  96.         $this->invoker $invoker;
  97.     }
  98.  
  99.     /**
  100.      *    Accessor for test case being run.
  101.      *    @return SimpleTestCase    Test case.
  102.      *    @access public
  103.      */
  104.     function getTestCase({
  105.         return $this->invoker->getTestCase();
  106.     }
  107.  
  108.     /**
  109.      *    Runs test level set up. Used for changing
  110.      *    the mechanics of base test cases.
  111.      *    @param string $method    Test method to call.
  112.      *    @access public
  113.      */
  114.     function before($method{
  115.         $this->invoker->before($method);
  116.     }
  117.  
  118.     /**
  119.      *    Invokes a test method and buffered with setUp()
  120.      *    and tearDown() calls.
  121.      *    @param string $method    Test method to call.
  122.      *    @access public
  123.      */
  124.     function invoke($method{
  125.         $this->invoker->invoke($method);
  126.     }
  127.  
  128.     /**
  129.      *    Runs test level clean up. Used for changing
  130.      *    the mechanics of base test cases.
  131.      *    @param string $method    Test method to call.
  132.      *    @access public
  133.      */
  134.     function after($method{
  135.         $this->invoker->after($method);
  136.     }
  137. }
  138. ?>

Documentation generated on Thu, 01 Oct 2009 20:55:02 -0500 by phpDocumentor 1.4.2