public function testReturnArrayIfNoConfig()
 {
     $moduleOptions = new ModuleOptions(['guards' => []]);
     $pluginManager = new GuardPluginManager();
     $serviceManager = new ServiceManager();
     $serviceManager->setService('ZfjRbac\\Options\\ModuleOptions', $moduleOptions);
     $pluginManager->setServiceLocator($serviceManager);
     $factory = new GuardsFactory();
     $guards = $factory->createService($serviceManager);
     $this->assertInternalType('array', $guards);
     $this->assertEmpty($guards);
 }
 public function testFactory()
 {
     $options = new ModuleOptions(['identity_provider' => 'ZfjRbac\\Identity\\AuthenticationProvider', 'guards' => ['ZfjRbac\\Guard\\ControllerGuard' => ['controller' => 'MyController', 'actions' => 'edit', 'roles' => 'member']], 'protection_policy' => GuardInterface::POLICY_ALLOW]);
     $serviceManager = new ServiceManager();
     $serviceManager->setService('ZfjRbac\\Options\\ModuleOptions', $options);
     $serviceManager->setService('ZfjRbac\\Service\\RoleService', $this->getMock('ZfjRbac\\Service\\RoleService', [], [], '', false));
     $pluginManager = new GuardPluginManager();
     $pluginManager->setServiceLocator($serviceManager);
     $factory = new ControllerGuardFactory();
     $controllerGuard = $factory->createService($pluginManager);
     $this->assertInstanceOf('ZfjRbac\\Guard\\ControllerGuard', $controllerGuard);
     $this->assertEquals(GuardInterface::POLICY_ALLOW, $controllerGuard->getProtectionPolicy());
 }
 public function testFactory()
 {
     $creationOptions = ['route' => 'role'];
     $options = new ModuleOptions(['identity_provider' => 'ZfjRbac\\Identity\\AuthenticationProvider', 'guards' => ['ZfjRbac\\Guard\\RoutePermissionsGuard' => $creationOptions], 'protection_policy' => GuardInterface::POLICY_ALLOW]);
     $serviceManager = new ServiceManager();
     $serviceManager->setService('ZfjRbac\\Options\\ModuleOptions', $options);
     $serviceManager->setService('ZfjRbac\\Service\\AuthorizationService', $this->getMock('ZfjRbac\\Service\\AuthorizationService', [], [], '', false));
     $pluginManager = new GuardPluginManager();
     $pluginManager->setServiceLocator($serviceManager);
     $factory = new RoutePermissionsGuardFactory();
     $routeGuard = $factory->createService($pluginManager);
     $this->assertInstanceOf('ZfjRbac\\Guard\\RoutePermissionsGuard', $routeGuard);
     $this->assertEquals(GuardInterface::POLICY_ALLOW, $routeGuard->getProtectionPolicy());
 }
 public function testThrowExceptionForInvalidPlugin()
 {
     $this->setExpectedException('ZfjRbac\\Exception\\RuntimeException');
     $pluginManager = new GuardPluginManager();
     $pluginManager->get('stdClass');
 }