FU r105154: only clear tables that tests specify as written to. This reduces the...
authorAaron Schulz <aaron@users.mediawiki.org>
Sat, 10 Dec 2011 05:47:46 +0000 (05:47 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Sat, 10 Dec 2011 05:47:46 +0000 (05:47 +0000)
Since previously (pre-r105154) nothing was cleared, tests should still work.

tests/phpunit/MediaWikiTestCase.php

index 7ce497a..fdc3b9b 100644 (file)
@@ -12,8 +12,9 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
        protected $oldTablePrefix;
        protected $useTemporaryTables = true;
        protected $reuseDB = false;
+       protected $tablesUsed = array(); // tables with data
+
        private static $dbSetup = false;
-       private static $tablesCloned = array();
 
        /**
         * Table name prefixes. Oracle likes it shorter.
@@ -55,7 +56,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
                        $this->oldTablePrefix = $wgDBprefix;
 
                        if( !self::$dbSetup ) {
-                               self::$tablesCloned = $this->initDB();
+                               $this->initDB();
                                self::$dbSetup = true;
                        }
 
@@ -156,8 +157,6 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
                if ( $this->db->getType() == 'oracle' ) {
                        $this->db->query( 'BEGIN FILL_WIKI_INFO; END;' );
                }
-
-               return $tablesCloned;
        }
 
        /**
@@ -170,13 +169,13 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
                                        wfGetLB()->closeAll();
                                        $this->db = wfGetDB( DB_MASTER );
                                } else {
-                                       foreach( self::$tablesCloned as $tbl ) {
+                                       foreach( $this->tablesUsed as $tbl ) {
                                                if( $tbl == 'interwiki') continue;
                                                $this->db->query( 'TRUNCATE TABLE '.$this->db->tableName($tbl), __METHOD__ );
                                        }
                                }
                        } else {
-                               foreach( self::$tablesCloned as $tbl ) {
+                               foreach( $this->tablesUsed as $tbl ) {
                                        if( $tbl == 'interwiki' || $tbl == 'user' ) continue;
                                        $this->db->delete( $tbl, '*', __METHOD__ );
                                }