diff options
author | Frédéric Guillot <fred@kanboard.net> | 2014-12-31 12:37:15 -0500 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2014-12-31 12:37:15 -0500 |
commit | 772804add8095eea9b3ec2a832c2f82fbb9a6fd5 (patch) | |
tree | 782a414d15f9091d04bcf3960a957f952958e548 /tests/units/ProjectPermissionTest.php | |
parent | 66f150d887a34d2b51ff14f22d0fd41a34f8cc77 (diff) |
Acl refactoring
Diffstat (limited to 'tests/units/ProjectPermissionTest.php')
-rw-r--r-- | tests/units/ProjectPermissionTest.php | 62 |
1 files changed, 49 insertions, 13 deletions
diff --git a/tests/units/ProjectPermissionTest.php b/tests/units/ProjectPermissionTest.php index b169b63e..3cbd6bec 100644 --- a/tests/units/ProjectPermissionTest.php +++ b/tests/units/ProjectPermissionTest.php @@ -62,14 +62,14 @@ class ProjectPermissionTest extends Base $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); // We allow the admin user - $this->assertTrue($pp->allowUser(1, 1)); - $this->assertTrue($pp->allowUser(1, 2)); + $this->assertTrue($pp->addMember(1, 1)); + $this->assertTrue($pp->addMember(1, 2)); // Non-existant project - $this->assertFalse($pp->allowUser(50, 1)); + $this->assertFalse($pp->addMember(50, 1)); // Non-existant user - $this->assertFalse($pp->allowUser(1, 50)); + $this->assertFalse($pp->addMember(1, 50)); // Both users should be allowed $this->assertEquals(array('1' => 'admin', '2' => 'unittest'), $pp->getMembers(1)); @@ -89,7 +89,7 @@ class ProjectPermissionTest extends Base $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); // We revoke our admin user (not existing row) - $this->assertFalse($pp->revokeUser(1, 1)); + $this->assertFalse($pp->revokeMember(1, 1)); // We should have nobody in the users list $this->assertEmpty($pp->getMembers(1)); @@ -99,7 +99,7 @@ class ProjectPermissionTest extends Base $this->assertFalse($pp->isUserAllowed(1, 2)); // We allow only the regular user - $this->assertTrue($pp->allowUser(1, 2)); + $this->assertTrue($pp->addMember(1, 2)); // All users should be allowed (admin and regular) $this->assertTrue($pp->isUserAllowed(1, 1)); @@ -109,13 +109,13 @@ class ProjectPermissionTest extends Base $this->assertEquals(array('2' => 'unittest'), $pp->getMembers(1)); // We allow our admin, we should have both in the list - $this->assertTrue($pp->allowUser(1, 1)); + $this->assertTrue($pp->addMember(1, 1)); $this->assertEquals(array('1' => 'admin', '2' => 'unittest'), $pp->getMembers(1)); $this->assertTrue($pp->isUserAllowed(1, 1)); $this->assertTrue($pp->isUserAllowed(1, 2)); // We revoke the regular user - $this->assertTrue($pp->revokeUser(1, 2)); + $this->assertTrue($pp->revokeMember(1, 2)); // Only admin should be allowed $this->assertTrue($pp->isUserAllowed(1, 1)); @@ -125,7 +125,7 @@ class ProjectPermissionTest extends Base $this->assertEquals(array('1' => 'admin'), $pp->getMembers(1)); // We revoke the admin user - $this->assertTrue($pp->revokeUser(1, 1)); + $this->assertTrue($pp->revokeMember(1, 1)); $this->assertEmpty($pp->getMembers(1)); // Only admin should be allowed again @@ -133,6 +133,42 @@ class ProjectPermissionTest extends Base $this->assertFalse($pp->isUserAllowed(1, 2)); } + public function testManager() + { + $p = new Project($this->container); + $pp = new ProjectPermission($this->container); + $u = new User($this->container); + + $this->assertEquals(2, $u->create(array('username' => 'unittest', 'password' => 'unittest'))); + + $this->assertEquals(1, $p->create(array('name' => 'UnitTest1'))); + $this->assertFalse($pp->isMember(1, 2)); + $this->assertFalse($pp->isManager(1, 2)); + + $this->assertEquals(2, $p->create(array('name' => 'UnitTest2'), 1, true)); + $this->assertFalse($pp->isMember(2, 2)); + $this->assertFalse($pp->isManager(2, 2)); + + $this->assertEquals(3, $p->create(array('name' => 'UnitTest3'), 2, true)); + $this->assertTrue($pp->isMember(3, 2)); + $this->assertTrue($pp->isManager(3, 2)); + + $this->assertEquals(4, $p->create(array('name' => 'UnitTest4'))); + + $this->assertTrue($pp->addManager(4, 2)); + $this->assertTrue($pp->isMember(4, 2)); + $this->assertTrue($pp->isManager(4, 2)); + + $this->assertEquals(5, $p->create(array('name' => 'UnitTest5'))); + $this->assertTrue($pp->addMember(5, 2)); + $this->assertTrue($pp->changeRole(5, 2, 1)); + $this->assertTrue($pp->isMember(5, 2)); + $this->assertTrue($pp->isManager(5, 2)); + $this->assertTrue($pp->changeRole(5, 2, 0)); + $this->assertTrue($pp->isMember(5, 2)); + $this->assertFalse($pp->isManager(5, 2)); + } + public function testUsersList() { $p = new Project($this->container); @@ -151,7 +187,7 @@ class ProjectPermissionTest extends Base ); // We allow only the regular user - $this->assertTrue($pp->allowUser(1, 2)); + $this->assertTrue($pp->addMember(1, 2)); $this->assertEquals( array(0 => 'Unassigned', 2 => 'unittest'), @@ -159,7 +195,7 @@ class ProjectPermissionTest extends Base ); // We allow the admin user - $this->assertTrue($pp->allowUser(1, 1)); + $this->assertTrue($pp->addMember(1, 1)); $this->assertEquals( array(0 => 'Unassigned', 1 => 'admin', 2 => 'unittest'), @@ -167,7 +203,7 @@ class ProjectPermissionTest extends Base ); // We revoke only the regular user - $this->assertTrue($pp->revokeUser(1, 2)); + $this->assertTrue($pp->revokeMember(1, 2)); $this->assertEquals( array(0 => 'Unassigned', 1 => 'admin'), @@ -175,7 +211,7 @@ class ProjectPermissionTest extends Base ); // We revoke only the admin user, we should have everybody - $this->assertTrue($pp->revokeUser(1, 1)); + $this->assertTrue($pp->revokeMember(1, 1)); $this->assertEquals( array(0 => 'Unassigned'), |