setRuleClass() публичный Метод

Set rule class.
public setRuleClass ( string $ruleClass )
$ruleClass string
Пример #1
0
 public function testSetRuleClass()
 {
     eval('class GoodRuleClass extends \\SimpleAcl\\Rule {}');
     $acl = new Acl();
     $acl->setRuleClass('GoodRuleClass');
     $this->assertEquals('GoodRuleClass', $acl->getRuleClass());
 }
Пример #2
0
 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'));
 }