Don't duplicate tables starting with unittest_ which can be left if a previous run...
authorMax Semenik <maxsem@users.mediawiki.org>
Thu, 2 Jun 2011 17:58:34 +0000 (17:58 +0000)
committerMax Semenik <maxsem@users.mediawiki.org>
Thu, 2 Jun 2011 17:58:34 +0000 (17:58 +0000)
tests/phpunit/MediaWikiTestCase.php

index 39d7d29..40f2d98 100644 (file)
@@ -188,12 +188,19 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
                return substr( $tableName, strlen( $wgDBprefix ) );
        }
 
+       static private function isNotUnittest( $table ) {
+               return strpos( $table, 'unittest_' ) !== 0;
+       }
+
        protected function listTables() {
                global $wgDBprefix;
 
                $tables = $this->db->listTables( $wgDBprefix, __METHOD__ );
                $tables = array_map( array( __CLASS__, 'unprefixTable' ), $tables );
 
+               // Don't duplicate test tables from the previous fataled run
+               $tables = array_filter( $tables, array( __CLASS__, 'isNotUnittest' ) );
+
                if ( $this->db->getType() == 'sqlite' ) {
                        $tables = array_flip( $tables );
                        // these are subtables of searchindex and don't need to be duped/dropped separately