- static $services = null;
-
- if ( !$services ) {
- $services = self::resetGlobalServices( $bootstrapConfig );
- }
- return $services;
- }
-
- /**
- * Reset global services, and install testing environment.
- * This is the testing equivalent of MediaWikiServices::resetGlobalInstance().
- * This should only be used to set up the testing environment, not when
- * running unit tests. Use MediaWikiTestCase::overrideMwServices() for that.
- *
- * @see MediaWikiServices::resetGlobalInstance()
- * @see prepareServices()
- * @see MediaWikiTestCase::overrideMwServices()
- *
- * @param Config|null $bootstrapConfig The bootstrap config to use with the new
- * MediaWikiServices.
- * @return MediaWikiServices
- */
- private static function resetGlobalServices( Config $bootstrapConfig = null ) {
- $oldServices = MediaWikiServices::getInstance();
- $oldConfigFactory = $oldServices->getConfigFactory();
- $oldLoadBalancerFactory = $oldServices->getDBLoadBalancerFactory();
-
- $testConfig = self::makeTestConfig( $bootstrapConfig );
-
- MediaWikiServices::resetGlobalInstance( $testConfig );
-
- $serviceLocator = MediaWikiServices::getInstance();
- self::installTestServices(
- $oldConfigFactory,
- $oldLoadBalancerFactory,
- $serviceLocator
- );
- return $serviceLocator;