diff --git a/lib/simpletestlib/errors.php b/lib/simpletestlib/errors.php index 14c4d062668..204f0b1e05e 100644 --- a/lib/simpletestlib/errors.php +++ b/lib/simpletestlib/errors.php @@ -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 } /** diff --git a/lib/simpletestlib/invoker.php b/lib/simpletestlib/invoker.php index 49b393c0fb7..b9f81ff5ab4 100644 --- a/lib/simpletestlib/invoker.php +++ b/lib/simpletestlib/invoker.php @@ -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 } /** diff --git a/lib/simpletestlib/readme_moodle.txt b/lib/simpletestlib/readme_moodle.txt index d2a28b4e3bc..e0015a8aa5a 100644 --- a/lib/simpletestlib/readme_moodle.txt +++ b/lib/simpletestlib/readme_moodle.txt @@ -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