MDL-17534 simpletest: temporary fix for exception problems

This commit is contained in:
skodak 2008-12-04 23:19:37 +00:00
parent 9d833e931c
commit 995821591d
3 changed files with 25 additions and 2 deletions

View 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
}
/**

View 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
}
/**

View 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