Esempio n. 1
0
 public function testSetRoleAccessWithRoleName()
 {
     $acl = new ACL();
     $acl->setRoleReadAccess("admin", true);
     $out = $acl->encode();
     $this->assertEquals(true, $out["role:admin"]["read"]);
     $acl->setRoleWriteAccess("admin", false);
     $out = $acl->encode();
     $this->assertEquals(false, $out["role:admin"]["write"]);
 }
Esempio n. 2
0
 public function testSaveRole()
 {
     $role = new Role();
     $role->setName("admin");
     $acl = new ACL();
     $acl->setPublicWriteAccess(true);
     // so it can be destroyed
     $role->setACL($acl);
     $role->save();
     $this->assertNotEmpty($role->getObjectId());
     $this->assertTrue($role->getUsers() instanceof Relation);
     $this->assertTrue($role->getRoles() instanceof Relation);
     $role->destroy();
 }
Esempio n. 3
0
 public function testGetRoles()
 {
     $user = new User();
     $user->setUsername("alice3");
     $user->setPassword("blabla");
     $user->signUp();
     $role = new Role();
     $role->setName("test_role");
     $acl = new ACL();
     $acl->setPublicWriteAccess(true);
     $acl->setPublicReadAccess(true);
     $role->setACL($acl);
     $rel = $role->getUsers();
     $rel->add($user);
     $role->save();
     $this->assertNotEmpty($role->getObjectId());
     $roles = $user->getRoles();
     $this->assertEquals("test_role", $roles[0]->getName());
     $user->destroy();
     $role->destroy();
 }