From 1b7bfdee4907dd32bcead43c5a62a43a828702bc Mon Sep 17 00:00:00 2001 From: X! Date: Fri, 31 Dec 2010 21:01:17 +0000 Subject: [PATCH] I made MySQL work, and broke SQLite in the process. I fix SQLite, and made MySQL break. Fixing MySQL again, hoping that SQLite works too. :) --- includes/db/CloneDatabase.php | 2 +- tests/phpunit/MediaWikiTestCase.php | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/includes/db/CloneDatabase.php b/includes/db/CloneDatabase.php index a553c9b612..5410d1412d 100644 --- a/includes/db/CloneDatabase.php +++ b/includes/db/CloneDatabase.php @@ -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__ ); diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index 1bdcf1c8d0..3ad8edcd1d 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -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;' ); -- 2.20.1