Esempio n. 1
0
 protected function prepareEnvironment()
 {
     global $wgMemc;
     // Don't share DB, storage, or memcached connections
     MediaWikiServices::resetChildProcessServices();
     FileBackendGroup::destroySingleton();
     LockManagerGroup::destroySingletons();
     JobQueueGroup::destroySingletons();
     ObjectCache::clear();
     RedisConnectionPool::destroySingletons();
     $wgMemc = null;
 }
 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);
 }