getMockServiceManager(); $requiredActionService = new RequiredActionService(); $requiredActionService->setServiceLocator($serviceManager); $requiredActionService->attachAction($this->getTestRequiredAction()); $requiredAction = $requiredActionService->getRequiredAction('testRequiredAction'); $this->assertEquals($requiredAction->getName(), 'testRequiredAction'); } public function testDetachAction() { $serviceManager = $this->getMockServiceManager(); $requiredActionService = new RequiredActionService(); $requiredActionService->setServiceLocator($serviceManager); $requiredActionService->attachAction($this->getTestRequiredAction()); $requiredAction = $requiredActionService->getRequiredAction('testRequiredAction'); $this->assertEquals($requiredAction->getName(), 'testRequiredAction'); $requiredActionService->detachAction('testRequiredAction'); $requiredAction = $requiredActionService->getRequiredAction('testRequiredAction'); $this->assertNull($requiredAction); } private function getTestRequiredAction() { return new RequiredActionRedirectUrlPart( 'testRequiredAction', [ new TimeRule(), ], [] ); } private function getPersistenceManager() { return new \common_persistence_Manager([ 'persistences' => [ 'test' => [ 'driver' => 'no_storage' ], ] ]); } private function getMockServiceManager() { $config = new \common_persistence_KeyValuePersistence([], new \common_persistence_InMemoryKvDriver()); $config->set(\common_persistence_Manager::SERVICE_ID, $this->getPersistenceManager()); return new ServiceManager($config); } }