X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fparser%2FParserTestRunner.php;h=3b63c19a94e84c35ca25afcbe2bab2758af8ef22;hb=25ee9366b06a44087e8f0cba1f2b27324259ef52;hp=b40b76927eea560ecd29691664fbf7e9c9c918df;hpb=7ecbff2360a07755f771c648ed1e27ee3dca8ad5;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/parser/ParserTestRunner.php b/tests/parser/ParserTestRunner.php index b40b76927e..3b63c19a94 100644 --- a/tests/parser/ParserTestRunner.php +++ b/tests/parser/ParserTestRunner.php @@ -289,9 +289,14 @@ class ParserTestRunner { // All FileRepo changes should be done here by injecting services, // there should be no need to change global variables. - RepoGroup::setSingleton( $this->createRepoGroup() ); + MediaWikiServices::getInstance()->disableService( 'RepoGroup' ); + MediaWikiServices::getInstance()->redefineService( 'RepoGroup', + function () { + return $this->createRepoGroup(); + } + ); $teardown[] = function () { - RepoGroup::destroySingleton(); + MediaWikiServices::getInstance()->resetServiceForTesting( 'RepoGroup' ); }; // Set up null lock managers @@ -449,7 +454,8 @@ class ParserTestRunner { 'transformVia404' => false, 'backend' => $backend ], - [] + [], + MediaWikiServices::getInstance()->getMainWANObjectCache() ); } @@ -635,6 +641,8 @@ class ParserTestRunner { /** * Reset the Title-related services that need resetting * for each test + * + * @todo We need to reset all services on every test */ private function resetTitleServices() { $services = MediaWikiServices::getInstance(); @@ -643,6 +651,7 @@ class ParserTestRunner { $services->resetServiceForTesting( '_MediaWikiTitleCodec' ); $services->resetServiceForTesting( 'LinkRenderer' ); $services->resetServiceForTesting( 'LinkRendererFactory' ); + $services->resetServiceForTesting( 'NamespaceInfo' ); } /** @@ -1071,7 +1080,8 @@ class ParserTestRunner { 'wgLanguageCode' => $langCode, 'wgRawHtml' => self::getOptionValue( 'wgRawHtml', $opts, false ), 'wgNamespacesWithSubpages' => array_fill_keys( - MWNamespace::getValidNamespaces(), isset( $opts['subpage'] ) + MediaWikiServices::getInstance()->getNamespaceInfo()->getValidNamespaces(), + isset( $opts['subpage'] ) ), 'wgMaxTocLevel' => $maxtoclevel, 'wgAllowExternalImages' => self::getOptionValue( 'wgAllowExternalImages', $opts, true ), @@ -1719,10 +1729,10 @@ class ParserTestRunner { * @return bool True if tag hook is present */ public function requireHook( $name ) { - global $wgParser; + $parser = MediaWikiServices::getInstance()->getParser(); - $wgParser->firstCallInit(); // make sure hooks are loaded. - if ( isset( $wgParser->mTagHooks[$name] ) ) { + $parser->firstCallInit(); // make sure hooks are loaded. + if ( isset( $parser->mTagHooks[$name] ) ) { return true; } else { $this->recorder->warning( " This test suite requires the '$name' hook " . @@ -1738,11 +1748,11 @@ class ParserTestRunner { * @return bool True if function hook is present */ public function requireFunctionHook( $name ) { - global $wgParser; + $parser = MediaWikiServices::getInstance()->getParser(); - $wgParser->firstCallInit(); // make sure hooks are loaded. + $parser->firstCallInit(); // make sure hooks are loaded. - if ( isset( $wgParser->mFunctionHooks[$name] ) ) { + if ( isset( $parser->mFunctionHooks[$name] ) ) { return true; } else { $this->recorder->warning( " This test suite requires the '$name' function " . @@ -1758,11 +1768,11 @@ class ParserTestRunner { * @return bool True if function hook is present */ public function requireTransparentHook( $name ) { - global $wgParser; + $parser = MediaWikiServices::getInstance()->getParser(); - $wgParser->firstCallInit(); // make sure hooks are loaded. + $parser->firstCallInit(); // make sure hooks are loaded. - if ( isset( $wgParser->mTransparentTagHooks[$name] ) ) { + if ( isset( $parser->mTransparentTagHooks[$name] ) ) { return true; } else { $this->recorder->warning( " This test suite requires the '$name' transparent " .