Author: Michaël Gallego (mic.gallego@gmail.com)
Inheritance: implements Zend\ServiceManager\FactoryInterface
コード例 #1
0
 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);
 }
コード例 #2
0
 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);
 }