public function testGetRoles() { $acl = new AccessMap(); $acl->setDefaultRole('role3'); $acl->add('MyController', 'myAction1', array('role1', 'role2')); $acl->add('MyController', 'myAction2', array('role1')); $acl->add('MyAdminController', '*', array('role2')); $this->assertEquals(array('role1', 'role2'), $acl->getRoles('mycontroller', 'MyAction1')); $this->assertEquals(array('role1'), $acl->getRoles('mycontroller', 'MyAction2')); $this->assertEquals(array('role2'), $acl->getRoles('Myadmincontroller', 'MyAction')); $this->assertEquals(array('role3'), $acl->getRoles('AnotherController', 'ActionNotFound')); }
public function testAddRulesAndGetRoles() { $acl = new AccessMap(); $acl->setDefaultRole('role3'); $acl->setRoleHierarchy('role2', array('role1')); $acl->add('MyController', 'myAction1', 'role2'); $acl->add('MyController', 'myAction2', 'role1'); $acl->add('MyAdminController', '*', 'role2'); $acl->add('SomethingElse', array('actionA', 'actionB'), 'role2'); $this->assertEquals(array('role2'), $acl->getRoles('mycontroller', 'MyAction1')); $this->assertEquals(array('role1', 'role2'), $acl->getRoles('mycontroller', 'MyAction2')); $this->assertEquals(array('role2'), $acl->getRoles('Myadmincontroller', 'MyAction')); $this->assertEquals(array('role3'), $acl->getRoles('AnotherController', 'ActionNotFound')); $this->assertEquals(array('role2'), $acl->getRoles('somethingelse', 'actiona')); $this->assertEquals(array('role2'), $acl->getRoles('somethingelse', 'actionb')); $this->assertEquals(array('role3'), $acl->getRoles('somethingelse', 'actionc')); }