Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/lib/simpletestlib/invoker.php
Go to the documentation of this file.
00001 <?php
00013 require_once(dirname(__FILE__) . '/errors.php');
00014 require_once(dirname(__FILE__) . '/compatibility.php');
00015 require_once(dirname(__FILE__) . '/scorer.php');
00016 require_once(dirname(__FILE__) . '/expectation.php');
00017 require_once(dirname(__FILE__) . '/dumper.php');
00018 if (! defined('SIMPLE_TEST')) {
00019     define('SIMPLE_TEST', dirname(__FILE__) . '/');
00020 }
00030 class SimpleInvoker {
00031     var $_test_case;
00032 
00037     function SimpleInvoker(&$test_case) {
00038         $this->_test_case = &$test_case;
00039     }
00040 
00046     function &getTestCase() {
00047         return $this->_test_case;
00048     }
00049 
00056     function before($method) {
00057         $this->_test_case->before($method);
00058     }
00059 
00066     function invoke($method) {
00067         $this->_test_case->setUp();
00068         // moodle hack start
00069         // note: this breaks PHP4 compatibility!
00070         $rethrow = null;
00071         try {
00072             $this->_test_case->$method();
00073         } catch (Exception $e) {
00074             $rethrow = $e;
00075         }
00076         $this->_test_case->tearDown();
00077         if ($rethrow) {
00078             throw $rethrow;
00079         }
00080         // moodle hack end
00081     }
00082 
00089     function after($method) {
00090         $this->_test_case->after($method);
00091     }
00092 }
00093 
00100 class SimpleInvokerDecorator {
00101     var $_invoker;
00102 
00107     function SimpleInvokerDecorator(&$invoker) {
00108         $this->_invoker = &$invoker;
00109     }
00110 
00116     function &getTestCase() {
00117         return $this->_invoker->getTestCase();
00118     }
00119 
00126     function before($method) {
00127         $this->_invoker->before($method);
00128     }
00129 
00136     function invoke($method) {
00137         $this->_invoker->invoke($method);
00138     }
00139 
00146     function after($method) {
00147         $this->_invoker->after($method);
00148     }
00149 }
00150 ?>
 All Data Structures Namespaces Files Functions Variables Enumerations