public function testSetRuleClass() { eval('class GoodRuleClass extends \\SimpleAcl\\Rule {}'); $acl = new Acl(); $acl->setRuleClass('GoodRuleClass'); $this->assertEquals('GoodRuleClass', $acl->getRuleClass()); }
public function testStringAsRule() { $acl = new Acl(); $user = new Role('User'); $resource = new Resource('Page'); $acl->addRule($user, $resource, 'View', true); $acl->addRule($user, $resource, 'Edit', true); $acl->addRule($user, $resource, 'Remove', true); $this->assertTrue($acl->isAllowed('User', 'Page', 'View')); $this->assertTrue($acl->isAllowed('User', 'Page', 'Edit')); $this->assertTrue($acl->isAllowed('User', 'Page', 'Remove')); $acl = new Acl(); $acl->setRuleClass('SimpleAcl\\Rule'); $user = new Role('User'); $resource = new Resource('Page'); $acl->addRule($user, $resource, 'View', false); $acl->addRule($user, $resource, 'Edit', false); $acl->addRule($user, $resource, 'Remove', false); $this->assertFalse($acl->isAllowed('User', 'Page', 'View')); $this->assertFalse($acl->isAllowed('User', 'Page', 'Edit')); $this->assertFalse($acl->isAllowed('User', 'Page', 'Remove')); }