From: Brad Jorsch Date: Mon, 8 Apr 2019 17:48:49 +0000 (-0400) Subject: MediaWikiTestCase: Fix schema restoration X-Git-Tag: 1.34.0-rc.0~2085^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/journal.php?a=commitdiff_plain;h=f552b10feaad7e99162742ff0602917aca183d3a;p=lhc%2Fweb%2Fwiklou.git 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 --- 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.