From: Alexandre Emsenhuber Date: Sat, 4 May 2013 12:21:39 +0000 (+0200) Subject: Fix global objects and singletons in NewParserTest X-Git-Tag: 1.31.0-rc.0~19658^2 X-Git-Url: https://git.cyclocoop.org/%27.%24link.%27?a=commitdiff_plain;h=00f891ce9084fd9f700c5bee553c549be394bf3b;p=lhc%2Fweb%2Fwiklou.git Fix global objects and singletons in NewParserTest - Don't set $wgMemc, $parserMemc and $messageMemc on each test, the correct values for $wgMainCacheType and such are already set in phpunit.php, so those objects are already the good ones - Only destroy RepoGroup and FileBackendGroup once before starting the tests instead of two - No need to clear the MessageCache in addDBData(), it is already destroyed in setupGlobals() (also avoids creating an object on some tests to only call clear() on it) - Group singleton cleanup after the test in tearDown() Change-Id: Ib2d6522019160f63f3f968e69940413a1def2f8b --- diff --git a/tests/phpunit/includes/parser/NewParserTest.php b/tests/phpunit/includes/parser/NewParserTest.php index f41c71cc76..7ec364d457 100644 --- a/tests/phpunit/includes/parser/NewParserTest.php +++ b/tests/phpunit/includes/parser/NewParserTest.php @@ -100,9 +100,6 @@ class NewParserTest extends MediaWikiTestCase { 'createtalk' => true, ) ); $tmpGlobals['wgNamespaceProtection'] = array( NS_MEDIAWIKI => 'editinterface' ); - $tmpGlobals['wgMemc'] = new EmptyBagOStuff; - $tmpGlobals['messageMemc'] = wfGetMessageCacheStorage(); - $tmpGlobals['parserMemc'] = wfGetParserCacheStorage(); $tmpGlobals['wgParser'] = new StubObject( 'wgParser', $GLOBALS['wgParserConf']['class'], array( $GLOBALS['wgParserConf'] ) ); @@ -142,6 +139,12 @@ class NewParserTest extends MediaWikiTestCase { RepoGroup::destroySingleton(); FileBackendGroup::destroySingleton(); + // Remove temporary pages from the link cache + LinkCache::singleton()->clear(); + + // Restore message cache (temporary pages and $wgUseDatabaseMessages) + MessageCache::destroyInstance(); + parent::tearDown(); } @@ -197,9 +200,6 @@ class NewParserTest extends MediaWikiTestCase { __METHOD__ ); - # Clear the message cache - MessageCache::singleton()->clear(); - $user = User::newFromId( 0 ); LinkCache::singleton()->clear(); # Avoids the odd failure at creating the nullRevision @@ -376,6 +376,8 @@ class NewParserTest extends MediaWikiTestCase { } MagicWord::clearCache(); + + # The entries saved into RepoGroup cache with previous globals will be wrong. RepoGroup::destroySingleton(); FileBackendGroup::destroySingleton(); @@ -385,9 +387,6 @@ class NewParserTest extends MediaWikiTestCase { # Publish the articles after we have the final language set $this->publishTestArticles(); - # The entries saved into RepoGroup cache with previous globals will be wrong. - RepoGroup::destroySingleton(); - FileBackendGroup::destroySingleton(); MessageCache::destroyInstance(); return $context; @@ -454,9 +453,6 @@ class NewParserTest extends MediaWikiTestCase { foreach ( $this->savedGlobals as $var => $val ) { $GLOBALS[$var] = $val; } - - RepoGroup::destroySingleton(); - LinkCache::singleton()->clear(); } /**