public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { /* @var \Rbac\Rbac $rbac */ $rbac = $container->get('Rbac\\Rbac'); /* @var \ZfjRbac\Service\RoleService $roleService */ $roleService = $container->get('ZfjRbac\\Service\\RoleService'); /* @var \ZfjRbac\Assertion\AssertionPluginManager $assertionPluginManager */ $assertionPluginManager = $container->get('ZfjRbac\\Assertion\\AssertionPluginManager'); /* @var \ZfjRbac\Options\ModuleOptions $moduleOptions */ $moduleOptions = $container->get('ZfjRbac\\Options\\ModuleOptions'); $authorizationService = new AuthorizationService($rbac, $roleService, $assertionPluginManager); $authorizationService->setAssertions($moduleOptions->getAssertionMap()); return $authorizationService; }
/** * @covers ZfjRbac\Service\AuthorizationService::getIdentity */ public function testGetIdentity() { $rbac = $this->getMock('Rbac\\Rbac', [], [], '', false); $identity = $this->getMock('ZfjRbac\\Identity\\IdentityInterface'); $roleService = $this->getMock('ZfjRbac\\Service\\RoleService', [], [], '', false); $assertionManager = $this->getMock('ZfjRbac\\Assertion\\AssertionPluginManager', [], [], '', false); $authorization = new AuthorizationService($rbac, $roleService, $assertionManager); $roleService->expects($this->once())->method('getIdentity')->will($this->returnValue($identity)); $this->assertSame($authorization->getIdentity(), $identity); }