]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-17534 simpletest: temporary fix for exception problems
authorskodak <skodak>
Thu, 4 Dec 2008 23:19:37 +0000 (23:19 +0000)
committerskodak <skodak>
Thu, 4 Dec 2008 23:19:37 +0000 (23:19 +0000)
lib/simpletestlib/errors.php
lib/simpletestlib/invoker.php
lib/simpletestlib/readme_moodle.txt

index 14c4d0626682a374bd1539e803a5b7e6f8d144bc..204f0b1e05e4c8aa0919659d5e5552585956462a 100644 (file)
@@ -46,9 +46,20 @@ class SimpleErrorTrappingInvoker extends SimpleInvokerDecorator {
     function invoke($method) {
         $queue = &$this->_createErrorQueue();
         set_error_handler('SimpleTestErrorHandler');
-        parent::invoke($method);
+        //moodle hack start
+        // note: this breaks PHP4 compatibility!
+        $rethrow = null;
+        try {
+            parent::invoke($method);
+        } catch (Exception $e) {
+            $rethrow = $e;
+        }
         restore_error_handler();
         $queue->tally();
+        if ($rethrow) {
+            throw $rethrow;
+        }
+        //moodle hack end
     }
     
     /**
index 49b393c0fb7843413a20b90b1367e09aa717e710..b9f81ff5ab4904a04788e9d89adc9f883e87a8ca 100644 (file)
@@ -65,8 +65,19 @@ class SimpleInvoker {
      */
     function invoke($method) {
         $this->_test_case->setUp();
-        $this->_test_case->$method();
+        // moodle hack start
+        // note: this breaks PHP4 compatibility!
+        $rethrow = null;
+        try {
+            $this->_test_case->$method();
+        } catch (Exception $e) {
+            $rethrow = $e;
+        }
         $this->_test_case->tearDown();
+        if ($rethrow) {
+            throw $rethrow;
+        }
+        // moodle hack end
     }
 
     /**
index d2a28b4e3bcb2e10884a064ed03211a67274e9e0..e0015a8aa5ad2bbbb8aa81f755827502d3d7b463 100644 (file)
@@ -2,6 +2,7 @@ Description of Simpletest 1.0.1beta library import into Moodle
 
 Changes:
  * test_case.php - added our global $CFG before include() MDL-10064
+ * fixed exception support (MDL-17534) - try/catch in invoker.php and errors.php
 
 skodak