I made MySQL work, and broke SQLite in the process. I fix SQLite, and made MySQL...
authorX! <soxred93@users.mediawiki.org>
Fri, 31 Dec 2010 21:01:17 +0000 (21:01 +0000)
committerX! <soxred93@users.mediawiki.org>
Fri, 31 Dec 2010 21:01:17 +0000 (21:01 +0000)
includes/db/CloneDatabase.php
tests/phpunit/MediaWikiTestCase.php

index a553c9b..5410d14 100644 (file)
@@ -96,7 +96,7 @@ class CloneDatabase {
                        
                        self::changePrefix( $this->newTablePrefix );
                        $newTableName = $this->db->tableName( $tbl );
-
+                       
                        if( $this->dropCurrentTables && !in_array( $this->db->getType(), array( 'postgres' ) ) ) {
                                $this->db->dropTable( $tbl, __METHOD__ );
                                wfDebug( "Dropping {$this->newTablePrefix}{$oldTableName}\n", __METHOD__ );
index 1bdcf1c..3ad8edc 100644 (file)
@@ -25,17 +25,27 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
        function run( PHPUnit_Framework_TestResult $result = NULL ) {
                
                if( $this->needsDB() ) {
+               
+                       global $wgDBprefix;
                        
                        $this->db = wfGetDB( DB_MASTER );
+                       $this->oldTablePrefix = $wgDBprefix;
                        
                        $this->destroyDB();
                        
                        $this->initDB();
                        $this->addCoreDBData();
                        $this->addDBData();
+                       
+                       parent::run( $result );
+               
+                       $this->destroyDB();
+               }
+               else {
+                       parent::run( $result );
+               
                }
                
-               parent::run( $result );
        }
        
        function __destruct() {
@@ -82,15 +92,13 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
                        throw new MWException( 'Cannot run unit tests, the database prefix is already "unittest_"' );
                }
 
-               $this->oldTablePrefix = $wgDBprefix;
-
                $tables = $this->listTables();
                
                $prefix = $dbType != 'oracle' ? 'unittest_' : 'ut_';
-
+               
                $this->dbClone = new CloneDatabase( $this->db, $tables, $prefix );
                $this->dbClone->cloneTableStructure();
-
+               
                if ( $dbType == 'oracle' )
                        $this->db->query( 'BEGIN FILL_WIKI_INFO; END;' );