Clean up transactions after test.
[lhc/web/wiklou.git] / tests / phpunit / MediaWikiTestCase.php
index c873c51..49c2a70 100644 (file)
@@ -115,7 +115,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
        }
 
        protected function tearDown() {
-               // Cleaning up temoporary files
+               // Cleaning up temporary files
                foreach ( $this->tmpfiles as $fname ) {
                        if ( is_file( $fname ) || ( is_link( $fname ) ) ) {
                                unlink( $fname );
@@ -124,6 +124,13 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
                        }
                }
 
+               // clean up open transactions
+               if( $this->needsDB() && $this->db ) {
+                       while( $this->db->trxLevel() > 0 ) {
+                               $this->db->rollback();
+                       }
+               }
+
                parent::tearDown();
        }