*/ class InstallActionTest extends TestCase { public function testRegisterEvent() { $event = 'testEvent'; $callBack = function () { }; $instance = $this->getMockForAbstractClass( InstallAction::class, [], '', false, false, true, ['getServiceLocator' , 'getServiceManager'] ); $prophetServiceManager = $this->prophesize(ServiceManager::class); $prophetEventManager = $this->prophesize(EventManager::class); $prophetEventManager->attach($event, $callBack)->willReturn(null); $EventManagerMock = $prophetEventManager->reveal(); $prophetServiceManager->get(EventManager::CONFIG_ID)->willReturn($EventManagerMock); $prophetServiceManager->register(EventManager::CONFIG_ID, $EventManagerMock)->willReturn(null); $serviceManagerMock = $prophetServiceManager->reveal(); $instance->expects($this->once()) ->method('getServiceLocator') ->willReturn($serviceManagerMock); $instance->expects($this->once()) ->method('getServiceManager') ->willReturn($serviceManagerMock); $instance->registerEvent($event, $callBack); } public function testRegisterService() { $fixtureService = 'test/service'; $instance = $this->getMockForAbstractClass( InstallAction::class, [], '', false, false, true, ['getServiceManager'] ); $serviceProphet = $this->prophesize()->willExtend(\oat\oatbox\service\ConfigurableService::class); $prophetServiceManager = $this->prophesize(ServiceManager::class); $serviceManagerMock = $prophetServiceManager->reveal(); $serviceProphet->setServiceLocator($serviceManagerMock)->willReturn($serviceProphet); $serviceMock = $serviceProphet->reveal(); $prophetServiceManager->register($fixtureService, $serviceMock)->willReturn(null); $serviceManagerMock = $prophetServiceManager->reveal(); $instance->expects($this->exactly(1)) ->method('getServiceManager') ->willReturn($serviceManagerMock); $instance->registerService($fixtureService, $serviceMock); } }