/** * {@inheritDoc} */ public function createService(ServiceLocatorInterface $serviceLocator) { $user = $serviceLocator->get('zfcuser_user_service'); $simpleIdentityProvider = new AuthenticationIdentityProvider($user->getAuthService()); $config = $serviceLocator->get('BjyAuthorize\\Config'); $simpleIdentityProvider->setDefaultRole($config['default_role']); $simpleIdentityProvider->setAuthenticatedRole($config['authenticated_role']); return $simpleIdentityProvider; }
/** * @covers \BjyAuthorize\Provider\Identity\AuthenticationIdentityProvider::setDefaultRole * @covers \BjyAuthorize\Provider\Identity\AuthenticationIdentityProvider::getDefaultRole * @covers \BjyAuthorize\Exception\InvalidRoleException::invalidRoleInstance */ public function testSetGetDefaultRole() { $this->provider->setDefaultRole('test'); $this->assertSame('test', $this->provider->getDefaultRole()); $role = $this->getMock('Zend\\Permissions\\Acl\\Role\\RoleInterface'); $this->provider->setDefaultRole($role); $this->assertSame($role, $this->provider->getDefaultRole()); $this->setExpectedException('BjyAuthorize\\Exception\\InvalidRoleException'); $this->provider->setDefaultRole(false); }
/** * @param AuthenticationService $authService * @param ServiceLocatorInterface $serviceLocator */ public function __construct(AuthenticationService $authService, ServiceLocatorInterface $serviceLocator) { parent::__construct($authService); $this->adminService = $serviceLocator->get(AdminService::class); }