From abf22b914af1928b598e06553ea486bb511f5feb Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 5 Dec 2012 17:13:21 +0100 Subject: [PATCH] While testing, turn off DataBase::ignoreErrors. Database errors should cause an exception, not return false, unless the test case, or the code under test, explicitely calls ignoreErrors(true). The DB object should be reset to fail fast and safe for every test. Change-Id: Ifc2a720ec46a1843d9ffb1488c54743a0099ef9d --- tests/phpunit/MediaWikiTestCase.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index a594202106..908c076ab7 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -171,11 +171,14 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { } } - // Clean up open transactions if ( $this->needsDB() && $this->db ) { + // Clean up open transactions while( $this->db->trxLevel() > 0 ) { $this->db->rollback(); } + + // don't ignore DB errors + $this->db->ignoreErrors( false ); } wfProfileOut( __METHOD__ ); @@ -193,11 +196,14 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { } } - // Clean up open transactions if ( $this->needsDB() && $this->db ) { + // Clean up open transactions while( $this->db->trxLevel() > 0 ) { $this->db->rollback(); } + + // don't ignore DB errors + $this->db->ignoreErrors( false ); } // Restore mw globals -- 2.20.1