public function testInitializer() { $authServiceClassName = 'ZfcRbac\\Service\\AuthorizationService'; $initializer = new AuthorizationServiceInitializer(); $instance = new AuthorizationAwareFake(); $serviceLocator = $this->prophesize(ServiceLocatorInterface::class)->willImplement(ContainerInterface::class); $authorizationService = $this->getMock('ZfcRbac\\Service\\AuthorizationService', [], [], '', false); $serviceLocator->get($authServiceClassName)->willReturn($authorizationService)->shouldBeCalled(); $initializer->initialize($instance, $serviceLocator->reveal()); $this->assertEquals($authorizationService, $instance->getAuthorizationService()); }
public function testInitializer() { $authServiceClassName = 'ZfcRbac\\Service\\AuthorizationService'; $initializer = new AuthorizationServiceInitializer(); $instance = new AuthorizationAwareFake(); $serviceLocator = $this->getMock('Zend\\ServiceManager\\ServiceLocatorInterface'); $authorizationService = $this->getMock('ZfcRbac\\Service\\AuthorizationService', [], [], '', false); $serviceLocator->expects($this->once())->method('get')->with($authServiceClassName)->will($this->returnValue($authorizationService)); $initializer->initialize($instance, $serviceLocator); $this->assertEquals($authorizationService, $instance->getAuthorizationService()); }