示例#1
0
 /**
  * @covers System_Acl_Loader_Options::load
  * @covers System_Acl_Loader_Options::<protected>
  */
 public function testLoadRules()
 {
     $this->object->setOptions(array(System_Acl_Loader_Options::ACL => array(System_Acl_Loader_Options::RULE_ALLOW => array('test' => array('test'), 'test1' => array('res-res_res', 'res1')))));
     $this->object->load();
     self::assertTrue($this->acl->isAllowed('test', 'test'));
     self::assertTrue($this->acl->isAllowed('test1', 'res1'));
     self::assertTrue($this->acl->has('res'));
     self::assertTrue($this->acl->inherits('res.res', 'res', true));
     self::assertTrue($this->acl->has('res.res'));
     self::assertTrue($this->acl->has('res.res.res'));
     self::assertFalse($this->acl->isAllowed('test1', 'res'));
     self::assertFalse($this->acl->isAllowed('test1', 'res.res'));
     self::assertTrue($this->acl->isAllowed('test1', 'res.res.res'));
 }
示例#2
0
 /**
  * Tests basic Resource inheritance
  *
  * @return void
  */
 public function testResourceInherits()
 {
     $resourceCity = new Zend_Acl_Resource('city');
     $resourceBuilding = new Zend_Acl_Resource('building');
     $resourceRoom = new Zend_Acl_Resource('room');
     $this->_acl->add($resourceCity)->add($resourceBuilding, $resourceCity->getResourceId())->add($resourceRoom, $resourceBuilding);
     $this->assertTrue($this->_acl->inherits($resourceBuilding, $resourceCity, true));
     $this->assertTrue($this->_acl->inherits($resourceRoom, $resourceBuilding, true));
     $this->assertTrue($this->_acl->inherits($resourceRoom, $resourceCity));
     $this->assertFalse($this->_acl->inherits($resourceCity, $resourceBuilding));
     $this->assertFalse($this->_acl->inherits($resourceBuilding, $resourceRoom));
     $this->assertFalse($this->_acl->inherits($resourceCity, $resourceRoom));
     $this->_acl->remove($resourceBuilding);
     $this->assertFalse($this->_acl->has($resourceRoom));
 }
示例#3
0
文件: DbTest.php 项目: kandy/system
 /**
  * @covers System_Acl_Loader_Db::load
  * @covers System_Acl_Loader_Db::<protected>
  */
 public function testLoadRules()
 {
     $this->createTableMocks('AclRole');
     $this->createTableMocks('AclResource');
     $this->createTableMocks('AclRule', array(array('role' => 'test', 'resource' => 'test', 'access' => true), array('role' => 'test1', 'resource' => 'res-res_res', 'access' => true), array('role' => 'test1', 'resource' => 'res1', 'access' => true)));
     $this->object->load();
     self::assertTrue($this->acl->isAllowed('test', 'test'));
     self::assertTrue($this->acl->isAllowed('test1', 'res1'));
     self::assertTrue($this->acl->has('res'));
     self::assertTrue($this->acl->inherits('res.res', 'res', true));
     self::assertTrue($this->acl->has('res.res'));
     self::assertTrue($this->acl->has('res.res.res'));
     self::assertFalse($this->acl->isAllowed('test1', 'res'));
     self::assertFalse($this->acl->isAllowed('test1', 'res.res'));
     self::assertTrue($this->acl->isAllowed('test1', 'res.res.res'));
 }