From f552b10feaad7e99162742ff0602917aca183d3a Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Mon, 8 Apr 2019 13:48:49 -0400 Subject: [PATCH] MediaWikiTestCase: Fix schema restoration First, after restoring the old schema it needs to clear the variable so it doesn't keep "restoring" again and again for every subsequent test class. Second, after restoring the old schema it needs to repopulate anything added by addCoreDBData() that was lost by dropping and recreating the affected tables, which is easiest done by calling $this->resetDB(). Change-Id: I549d10eb7ceec117d3a0138449ca01f8065707d4 --- tests/phpunit/MediaWikiTestCase.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index 8a38f42b41..f1bb632300 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -1616,6 +1616,10 @@ abstract class MediaWikiTestCase extends PHPUnit\Framework\TestCase { if ( $tablesToRestore ) { $this->recloneMockTables( $db, $tablesToRestore ); + + // Reset the restored tables, mainly for the side effect of + // re-calling $this->addCoreDBData() if necessary. + $this->resetDB( $db, $tablesToRestore ); } } @@ -1630,6 +1634,7 @@ abstract class MediaWikiTestCase extends PHPUnit\Framework\TestCase { if ( $oldOverrides['alter'] || $oldOverrides['create'] || $oldOverrides['drop'] ) { $this->undoSchemaOverrides( $db, $oldOverrides ); + unset( $db->_schemaOverrides ); } // Determine new overrides. -- 2.20.1