getCollection() public method

public getCollection ( ) : array | string[]
return array | string[]
コード例 #1
0
 /**
  * Base method for the *collectPermissionProperty tests
  * @param RoleInterface $role
  * @return array|\string[]
  */
 private function collectPermissionsPropertyTestBase(RoleInterface $role)
 {
     $serviceManager = $this->getMock('Zend\\ServiceManager\\ServiceLocatorInterface');
     $application = $this->getMock('Zend\\Mvc\\Application', [], [], '', false);
     $application->expects($this->once())->method('getServiceManager')->will($this->returnValue($serviceManager));
     $mvcEvent = new MvcEvent();
     $mvcEvent->setApplication($application);
     $identity = $this->getMock('ZfcRbac\\Identity\\IdentityInterface');
     $identity->expects($this->once())->method('getRoles')->will($this->returnValue([$role]));
     $identityProvider = $this->getMock('ZfcRbac\\Identity\\IdentityProviderInterface');
     $identityProvider->expects($this->once())->method('getIdentity')->will($this->returnValue($identity));
     $roleProvider = $this->getMock('ZfcRbac\\Role\\RoleProviderInterface');
     $roleService = new RoleService($identityProvider, $roleProvider, new RecursiveRoleIteratorStrategy());
     $serviceManager->expects($this->at(0))->method('get')->with('ZfcRbac\\Service\\RoleService')->will($this->returnValue($roleService));
     $serviceManager->expects($this->at(1))->method('get')->with('ZfcRbac\\Options\\ModuleOptions')->will($this->returnValue(new ModuleOptions()));
     $collector = new RbacCollector();
     $collector->collect($mvcEvent);
     $collector->unserialize($collector->serialize());
     return $collector->getCollection();
 }
コード例 #2
0
ファイル: RbacCollectorTest.php プロジェクト: htw-pk15/vufind
 public function testCanCollect()
 {
     $dataToCollect = ['module_options' => ['guest_role' => 'guest', 'protection_policy' => GuardInterface::POLICY_ALLOW, 'guards' => ['ZfcRbac\\Guard\\RouteGuard' => ['admin*' => ['*']], 'ZfcRbac\\Guard\\ControllerGuard' => [['controller' => 'Foo', 'roles' => ['*']]]]], 'role_config' => ['member' => ['children' => ['guest'], 'permissions' => ['write', 'delete']], 'guest' => ['permissions' => ['read']]], 'identity_role' => 'member'];
     $serviceManager = $this->getMock('Zend\\ServiceManager\\ServiceLocatorInterface');
     $application = $this->getMock('Zend\\Mvc\\Application', [], [], '', false);
     $application->expects($this->once())->method('getServiceManager')->will($this->returnValue($serviceManager));
     $mvcEvent = new MvcEvent();
     $mvcEvent->setApplication($application);
     $identity = $this->getMock('ZfcRbac\\Identity\\IdentityInterface');
     $identity->expects($this->once())->method('getRoles')->will($this->returnValue($dataToCollect['identity_role']));
     $identityProvider = $this->getMock('ZfcRbac\\Identity\\IdentityProviderInterface');
     $identityProvider->expects($this->once())->method('getIdentity')->will($this->returnValue($identity));
     $roleService = new RoleService($identityProvider, new InMemoryRoleProvider($dataToCollect['role_config']), new RecursiveRoleIteratorStrategy());
     $serviceManager->expects($this->at(0))->method('get')->with('ZfcRbac\\Service\\RoleService')->will($this->returnValue($roleService));
     $serviceManager->expects($this->at(1))->method('get')->with('ZfcRbac\\Options\\ModuleOptions')->will($this->returnValue(new ModuleOptions($dataToCollect['module_options'])));
     $collector = new RbacCollector();
     $collector->collect($mvcEvent);
     $collector->unserialize($collector->serialize());
     $collection = $collector->getCollection();
     $expectedCollection = ['options' => ['guest_role' => 'guest', 'protection_policy' => 'allow'], 'guards' => ['ZfcRbac\\Guard\\RouteGuard' => ['admin*' => ['*']], 'ZfcRbac\\Guard\\ControllerGuard' => [['controller' => 'Foo', 'roles' => ['*']]]], 'roles' => ['member' => ['guest']], 'permissions' => ['member' => ['write', 'delete'], 'guest' => ['read']]];
     $this->assertEquals($expectedCollection, $collection);
 }