当前位置: 首页>>代码示例>>PHP>>正文


PHP MediaWikiServices::forceGlobalInstance方法代码示例

本文整理汇总了PHP中MediaWiki\MediaWikiServices::forceGlobalInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP MediaWikiServices::forceGlobalInstance方法的具体用法?PHP MediaWikiServices::forceGlobalInstance怎么用?PHP MediaWikiServices::forceGlobalInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MediaWiki\MediaWikiServices的用法示例。


在下文中一共展示了MediaWikiServices::forceGlobalInstance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testResetChildProcessServices

 public function testResetChildProcessServices()
 {
     $newServices = $this->newMediaWikiServices();
     $oldServices = MediaWikiServices::forceGlobalInstance($newServices);
     $service1 = $this->getMock(DestructibleService::class);
     $service1->expects($this->once())->method('destroy');
     $service2 = $this->getMock(DestructibleService::class);
     $service2->expects($this->never())->method('destroy');
     // sequence of values the instantiator will return
     $instantiatorReturnValues = [$service1, $service2];
     $newServices->defineService('Test', function () use(&$instantiatorReturnValues) {
         return array_shift($instantiatorReturnValues);
     });
     // force the service to become active, so we can check that it does get destroyed
     $oldTestService = $newServices->getService('Test');
     MediaWikiServices::resetChildProcessServices();
     $finalServices = MediaWikiServices::getInstance();
     $newTestService = $finalServices->getService('Test');
     $this->assertNotSame($oldTestService, $newTestService);
     MediaWikiServices::forceGlobalInstance($oldServices);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:21,代码来源:MediaWikiServicesTest.php

示例2: overrideMwServices

 /**
  * 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;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:36,代码来源:MediaWikiTestCase.php


注:本文中的MediaWiki\MediaWikiServices::forceGlobalInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。