/**
  * @param \Zend\ServiceManager\AbstractPluginManager|ServiceLocatorInterface $serviceLocator
  * @return RouteGuard
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $parentLocator = $serviceLocator->getServiceLocator();
     /* @var \ZfjRbac\Options\ModuleOptions $moduleOptions */
     $moduleOptions = $parentLocator->get('ZfjRbac\\Options\\ModuleOptions');
     /* @var \ZfjRbac\Service\AuthorizationService $authorizationService */
     $authorizationService = $parentLocator->get('ZfjRbac\\Service\\AuthorizationService');
     $guard = new ControllerPermissionsGuard($authorizationService, $this->options);
     $guard->setProtectionPolicy($moduleOptions->getProtectionPolicy());
     return $guard;
 }
 /**
  * @dataProvider controllerDataProvider
  */
 public function testControllerGranted(array $rules, $controller, $action, $identityPermissions, $isGranted, $protectionPolicy)
 {
     $routeMatch = new RouteMatch([]);
     $routeMatch->setParam('controller', $controller);
     $routeMatch->setParam('action', $action);
     $authorizationService = $this->getMockAuthorizationService();
     $authorizationService->expects($this->any())->method('isGranted')->will($this->returnValueMap($identityPermissions));
     $controllerGuard = new ControllerPermissionsGuard($authorizationService, $rules);
     $controllerGuard->setProtectionPolicy($protectionPolicy);
     $event = new MvcEvent();
     $event->setRouteMatch($routeMatch);
     $this->assertEquals($isGranted, $controllerGuard->isGranted($event));
 }