Example #1
0
 /**
  * @depends testAddRole
  */
 public function testLoadResourceAssert()
 {
     $this->service->addRole('role1');
     $pluginManager = new AssertionManager();
     $pluginManager->setService('testAssert', new MockAssertion1());
     $mockStorage = $this->getMockBuilder('AclMan\\Storage\\Adapter\\ArrayAdapter\\ArrayAdapter')->disableOriginalConstructor()->setMethods(['hasResource', 'getPermissions', 'hasRole', 'getParentRoles'])->getMock();
     $mockStorage->expects($this->any())->method('hasResource')->will($this->returnValue(true));
     $permission = $this->getMockBuilder('AclMan\\Permission\\GenericPermission')->disableOriginalConstructor()->setMethods(['getAssertion', 'isAllow', 'getPrivilege', 'getResourceId', 'getRoleId'])->getMock();
     $permission->expects($this->any())->method('getRoleId')->will($this->returnValue('role1'));
     $permission->expects($this->any())->method('getResourceId')->will($this->returnValue('resource1'));
     $permission->expects($this->any())->method('getPrivilege')->will($this->returnValue('view'));
     $permission->expects($this->any())->method('getAssertion')->will($this->returnValue('testAssert'));
     $permission->expects($this->any())->method('isAllow')->will($this->returnValue(false));
     $mockStorage->expects($this->any())->method('getPermissions')->will($this->returnValue([$permission]));
     $this->service->setStorage($mockStorage);
     $this->service->setPluginManager($pluginManager);
     $this->assertTrue($this->service->loadResource('role1', 'resource1'));
 }