/** * @dataProvider routeDataProvider */ public function testRouteGranted(array $rules, $matchedRouteName, array $rolesConfig, $identityRole, $isGranted, $protectionPolicy) { $event = new MvcEvent(); $routeMatch = new RouteMatch([]); $routeMatch->setMatchedRouteName($matchedRouteName); $event->setRouteMatch($routeMatch); $identity = $this->getMock('ZfjRbac\\Identity\\IdentityInterface'); $identity->expects($this->any())->method('getRoles')->will($this->returnValue($identityRole)); $identityProvider = $this->getMock('ZfjRbac\\Identity\\IdentityProviderInterface'); $identityProvider->expects($this->any())->method('getIdentity')->will($this->returnValue($identity)); $roleProvider = new InMemoryRoleProvider($rolesConfig); $roleService = new RoleService($identityProvider, $roleProvider, new RecursiveRoleIteratorStrategy()); $routeGuard = new RouteGuard($roleService, $rules); $routeGuard->setProtectionPolicy($protectionPolicy); $this->assertEquals($isGranted, $routeGuard->isGranted($event)); }