/**
  * @return MediaWikiServices
  */
 private function newMediaWikiServices(Config $config = null)
 {
     if ($config === null) {
         $config = $this->newTestConfig();
     }
     $instance = new MediaWikiServices($config);
     // Load the default wiring from the specified files.
     $wiringFiles = $config->get('ServiceWiringFiles');
     $instance->loadWiringFiles($wiringFiles);
     return $instance;
 }
 /**
  * Stashes the global instance of MediaWikiServices, and installs a new one,
  * allowing test cases to override settings and services.
  * The previous instance of MediaWikiServices will be restored on tearDown.
  *
  * @since 1.27
  *
  * @param Config $configOverrides Configuration overrides for the new MediaWikiServices instance.
  * @param callable[] $services An associative array of services to re-define. Keys are service
  *        names, values are callables.
  *
  * @return MediaWikiServices
  * @throws MWException
  */
 protected function overrideMwServices(Config $configOverrides = null, array $services = [])
 {
     if (!$configOverrides) {
         $configOverrides = new HashConfig();
     }
     $oldInstance = MediaWikiServices::getInstance();
     $oldConfigFactory = $oldInstance->getConfigFactory();
     $testConfig = self::makeTestConfig(null, $configOverrides);
     $newInstance = new MediaWikiServices($testConfig);
     // Load the default wiring from the specified files.
     // NOTE: this logic mirrors the logic in MediaWikiServices::newInstance.
     $wiringFiles = $testConfig->get('ServiceWiringFiles');
     $newInstance->loadWiringFiles($wiringFiles);
     // Provide a traditional hook point to allow extensions to configure services.
     Hooks::run('MediaWikiServices', [$newInstance]);
     foreach ($services as $name => $callback) {
         $newInstance->redefineService($name, $callback);
     }
     self::installTestServices($oldConfigFactory, $newInstance);
     MediaWikiServices::forceGlobalInstance($newInstance);
     return $newInstance;
 }