While testing, turn off DataBase::ignoreErrors.
authordaniel <daniel.kinzler@wikimedia.de>
Wed, 5 Dec 2012 16:13:21 +0000 (17:13 +0100)
committerdaniel <daniel.kinzler@wikimedia.de>
Wed, 5 Dec 2012 16:13:21 +0000 (17:13 +0100)
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

index a594202..908c076 100644 (file)
@@ -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