mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-52284 core: compatibility with Exception/Throwable changes in PHP7
This commit is contained in:
parent
0dfcc2541a
commit
d74b7e424f
7 changed files with 43 additions and 8 deletions
|
@ -88,7 +88,13 @@ abstract class advanced_testcase extends base_testcase {
|
|||
trigger_error('Unexpected debugging() call detected.', E_USER_NOTICE);
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
} catch (Exception $ex) {
|
||||
$e = $ex;
|
||||
} catch (Throwable $ex) {
|
||||
$e = $ex; // PHP7.
|
||||
}
|
||||
|
||||
if (isset($e)) {
|
||||
// cleanup after failed expectation
|
||||
self::resetAllData();
|
||||
throw $e;
|
||||
|
|
|
@ -62,7 +62,14 @@ abstract class basic_testcase extends base_testcase {
|
|||
|
||||
try {
|
||||
parent::runBare();
|
||||
} catch (Exception $e) {
|
||||
|
||||
} catch (Exception $ex) {
|
||||
$e = $ex;
|
||||
} catch (Throwable $ex) {
|
||||
$e = $ex; // PHP7.
|
||||
}
|
||||
|
||||
if (isset($e)) {
|
||||
// cleanup after failed expectation
|
||||
phpunit_util::reset_all_data();
|
||||
throw $e;
|
||||
|
|
|
@ -142,7 +142,13 @@ abstract class database_driver_testcase extends base_testcase {
|
|||
try {
|
||||
parent::runBare();
|
||||
|
||||
} catch (Exception $e) {
|
||||
} catch (Exception $ex) {
|
||||
$e = $ex;
|
||||
} catch (Throwable $ex) {
|
||||
$e = $ex; // PHP7.
|
||||
}
|
||||
|
||||
if (isset($e)) {
|
||||
if ($this->tdb->is_transaction_started()) {
|
||||
$this->tdb->force_transaction_rollback();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue