public function testDelegatorFactory() { $authServiceClassName = 'ZfcRbac\\Service\\AuthorizationService'; $delegator = new AuthorizationServiceDelegatorFactory(); $serviceLocator = $this->getMock('Zend\\ServiceManager\\ServiceLocatorInterface'); $authorizationService = $this->getMock('ZfcRbac\\Service\\AuthorizationService', [], [], '', false); $callback = function () { return new AuthorizationAwareFake(); }; $serviceLocator->expects($this->once())->method('get')->with($authServiceClassName)->will($this->returnValue($authorizationService)); $decoratedInstance = $delegator->createDelegatorWithName($serviceLocator, 'name', 'requestedName', $callback); $this->assertEquals($authorizationService, $decoratedInstance->getAuthorizationService()); }
public function testDelegatorFactory() { $authServiceClassName = 'ZfcRbac\\Service\\AuthorizationService'; $delegator = new AuthorizationServiceDelegatorFactory(); $serviceLocator = $this->prophesize(ServiceLocatorInterface::class); $serviceLocator->willImplement(ContainerInterface::class); $authorizationService = $this->getMock('ZfcRbac\\Service\\AuthorizationService', [], [], '', false); $callback = function () { return new AuthorizationAwareFake(); }; $serviceLocator->get($authServiceClassName)->willReturn($authorizationService)->shouldBeCalled(); $decoratedInstance = $delegator->createDelegatorWithName($serviceLocator->reveal(), 'name', 'requestedName', $callback); $this->assertEquals($authorizationService, $decoratedInstance->getAuthorizationService()); }