From aca26e064180b1bdf5bd6cd4b4d4562706d4798d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20S=CC=8Ckoda?= Date: Sun, 24 Mar 2013 14:16:28 +0100 Subject: [PATCH] MDL-37782 reset DB after each failed database test Conflicts: lib/phpunit/classes/database_driver_testcase.php --- .../classes/database_driver_testcase.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/phpunit/classes/database_driver_testcase.php b/lib/phpunit/classes/database_driver_testcase.php index dc075964676..953fa11d3cd 100644 --- a/lib/phpunit/classes/database_driver_testcase.php +++ b/lib/phpunit/classes/database_driver_testcase.php @@ -133,4 +133,21 @@ abstract class database_driver_testcase extends PHPUnit_Framework_TestCase { phpunit_util::reset_all_data(); parent::tearDownAfterClass(); } + + /** + * Runs the bare test sequence. + * @return void + */ + public function runBare() { + try { + parent::runBare(); + + } catch (Exception $e) { + if ($this->tdb->is_transaction_started()) { + $this->tdb->force_transaction_rollback(); + } + $this->tearDown(); + throw $e; + } + } }