Esempio n. 1
0
 /**
  * @tesdox Test adding custom child roles works
  */
 public function testAddCustomChildRole()
 {
     $role = $this->getMockForAbstractClass('Zend\\Permissions\\Rbac\\RoleInterface');
     $this->rbac->setCreateMissingRoles(true)->addRole($role, array('parent'));
     $role->expects($this->any())->method('getName')->will($this->returnValue('customchild'));
     $role->expects($this->once())->method('hasPermission')->with('test')->will($this->returnValue(true));
     $this->assertTrue($this->rbac->isGranted('parent', 'test'));
 }
Esempio n. 2
0
 public function testAddRoleWithAutomaticParentsUsingRbac()
 {
     $foo = new Rbac\Role('foo');
     $bar = new Rbac\Role('bar');
     $this->rbac->setCreateMissingRoles(true);
     $this->rbac->addRole($bar, $foo);
     $this->assertEquals($bar->getParent(), $foo);
     $this->assertEquals(1, count($foo->getChildren()));
 }