Skip to content

Commit

Permalink
MDL-17534 simpletest: temporary fix for exception problems
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Dec 4, 2008
1 parent 9d833e9 commit 9958215
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
13 changes: 12 additions & 1 deletion lib/simpletestlib/errors.php
Expand Up @@ -46,9 +46,20 @@ function SimpleErrorTrappingInvoker(&$invoker) {
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
}

/**
Expand Down
13 changes: 12 additions & 1 deletion lib/simpletestlib/invoker.php
Expand Up @@ -65,8 +65,19 @@ function before($method) {
*/
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
}

/**
Expand Down
1 change: 1 addition & 0 deletions lib/simpletestlib/readme_moodle.txt
Expand Up @@ -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

Expand Down

0 comments on commit 9958215

Please sign in to comment.