示例#1
0
 /**
  * Deny all and allow some resource
  */
 public function testDenyFive()
 {
     $adapter = new Miao_Acl_Adapter_Default();
     $acl = new Miao_Acl($adapter);
     $acl->addGroup('root');
     $acl->addGroup('manager1');
     $acl->addGroup('manager2');
     $acl->addGroup('guest');
     $acl->addResource('Article');
     $acl->addResource('Photo');
     $acl->deny('*', 'Article');
     $acl->allow('manager1', 'Article');
     $this->assertTrue($acl->isAllowed('manager1', 'Article'));
     $this->assertFalse($acl->isAllowed('manager2', 'Article'));
 }
示例#2
0
 public function testMain()
 {
     $adapter = new Miao_Acl_Adapter_Default();
     $acl = new Miao_Acl($adapter);
     $acl->addGroup('root');
     $acl->addGroup('guest');
     $acl->addGroup('editor');
     $acl->addResource('Article');
     $acl->addResource('Foto');
     $acl->allow('root');
     $acl->allow('guest', 'Article', array('view'));
     $acl->allow('guest', 'Foto', array('view'));
     $acl->allow('editor', 'Article');
     $acl->allow('editor', 'Foto', array('view', 'edit'));
     $this->assertTrue($acl->isAllowed('root', 'Foto'));
     $this->assertTrue($acl->isAllowed('root', 'Article', 'view'));
     $this->assertTrue($acl->isAllowed('root', 'Article', 'edit'));
     $this->assertTrue($acl->isAllowed('guest', 'Article'));
     $this->assertTrue($acl->isAllowed('guest', 'Article', 'view'));
     $this->assertFalse($acl->isAllowed('guest', 'Article', 'edit'));
     $this->assertTrue($acl->isAllowed('editor', 'Article', 'view'));
     $this->assertTrue($acl->isAllowed('editor', 'Article', 'edit'));
     $this->assertTrue($acl->isAllowed('editor', 'Foto', 'view'));
     $this->assertFalse($acl->isAllowed('editor', 'Foto', 'del'));
     $acl->deny('guest', 'Article');
     $this->assertFalse($acl->isAllowed('guest', 'Article', 'view'));
     $this->assertTrue($acl->isAllowed('root', 'Article', 'archive'));
     $acl->deny(null, 'Article', array('archive'));
     $this->assertFalse($acl->isAllowed('root', 'Article', 'archive'));
 }