public function testFactory() { $redirectStrategyOptions = $this->getMock('ZfcRbac\\Options\\RedirectStrategyOptions'); $moduleOptionsMock = $this->getMock('ZfcRbac\\Options\\ModuleOptions'); $moduleOptionsMock->expects($this->once())->method('getRedirectStrategy')->will($this->returnValue($redirectStrategyOptions)); $authenticationServiceMock = $this->getMock('Zend\\Authentication\\AuthenticationService'); $serviceLocatorMock = $this->getMock('Zend\\ServiceManager\\ServiceLocatorInterface'); $serviceLocatorMock->expects($this->at(0))->method('get')->with('ZfcRbac\\Options\\ModuleOptions')->will($this->returnValue($moduleOptionsMock)); $serviceLocatorMock->expects($this->at(1))->method('get')->with('Zend\\Authentication\\AuthenticationService')->will($this->returnValue($authenticationServiceMock)); $factory = new RedirectStrategyFactory(); $redirectStrategy = $factory->createService($serviceLocatorMock); $this->assertInstanceOf('ZfcRbac\\View\\Strategy\\RedirectStrategy', $redirectStrategy); }
public function testFactory() { $redirectStrategyOptions = $this->getMock('ZfcRbac\\Options\\RedirectStrategyOptions'); $moduleOptionsMock = $this->getMock('ZfcRbac\\Options\\ModuleOptions'); $moduleOptionsMock->expects($this->once())->method('getRedirectStrategy')->will($this->returnValue($redirectStrategyOptions)); $authenticationServiceMock = $this->getMock('Zend\\Authentication\\AuthenticationService'); $serviceLocatorMock = $this->prophesize(ServiceLocatorInterface::class); $serviceLocatorMock->willImplement(ContainerInterface::class); $serviceLocatorMock->get('ZfcRbac\\Options\\ModuleOptions')->willReturn($moduleOptionsMock)->shouldBeCalled(); $serviceLocatorMock->get('Zend\\Authentication\\AuthenticationService')->willReturn($authenticationServiceMock)->shouldBeCalled(); $factory = new RedirectStrategyFactory(); $redirectStrategy = $factory->createService($serviceLocatorMock->reveal()); $this->assertInstanceOf('ZfcRbac\\View\\Strategy\\RedirectStrategy', $redirectStrategy); }