// 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
'transformVia404' => false,
'backend' => $backend
],
- []
+ [],
+ MediaWikiServices::getInstance()->getMainWANObjectCache()
);
}
/**
* 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();
$services->resetServiceForTesting( '_MediaWikiTitleCodec' );
$services->resetServiceForTesting( 'LinkRenderer' );
$services->resetServiceForTesting( 'LinkRendererFactory' );
+ $services->resetServiceForTesting( 'NamespaceInfo' );
}
/**
$class = $wgParserConf['class'];
$parser = new $class( [ 'preprocessorClass' => $preprocessor ] + $wgParserConf );
+ if ( $preprocessor ) {
+ # Suppress deprecation warning for Preprocessor_DOM while testing
+ Wikimedia\suppressWarnings();
+ wfDeprecated( 'Preprocessor_DOM::__construct' );
+ Wikimedia\restoreWarnings();
+ $parser->getPreprocessor();
+ }
ParserTestParserHook::setup( $parser );
return $parser;
'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 ),