From 28bc4246bff405367c9e5640bca356b307962026 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Sat, 1 Mar 2014 19:51:09 -0500 Subject: Add acl and access list for projects --- tests/ProjectTest.php | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 tests/ProjectTest.php (limited to 'tests/ProjectTest.php') diff --git a/tests/ProjectTest.php b/tests/ProjectTest.php new file mode 100644 index 00000000..6eb39f52 --- /dev/null +++ b/tests/ProjectTest.php @@ -0,0 +1,63 @@ +assertEquals(1, $p->create(array('name' => 'UnitTest'))); + $this->assertNotEmpty($p->getById(1)); + } + + public function testAllowUsers() + { + $p = new Project; + + // Everybody is allowed + $this->assertEmpty($p->getAllowedUsers(1)); + $this->assertTrue($p->isUserAllowed(1, 1)); + + // Allow one user + $this->assertTrue($p->allowUser(1, 1)); + $this->assertFalse($p->allowUser(50, 1)); + $this->assertFalse($p->allowUser(1, 50)); + $this->assertEquals(array('1' => 'admin'), $p->getAllowedUsers(1)); + $this->assertTrue($p->isUserAllowed(1, 1)); + + // Disallow one user + $this->assertTrue($p->revokeUser(1, 1)); + $this->assertEmpty($p->getAllowedUsers(1)); + $this->assertTrue($p->isUserAllowed(1, 1)); + + // Allow/disallow many users + $user = new User; + $user->create(array('username' => 'unittest', 'password' => 'unittest')); + + $this->assertTrue($p->allowUser(1, 1)); + $this->assertTrue($p->allowUser(1, 2)); + + $this->assertEquals(array('1' => 'admin', '2' => 'unittest'), $p->getAllowedUsers(1)); + $this->assertTrue($p->isUserAllowed(1, 1)); + $this->assertTrue($p->isUserAllowed(1, 2)); + + $this->assertTrue($p->revokeUser(1, 1)); + + $this->assertEquals(array('2' => 'unittest'), $p->getAllowedUsers(1)); + $this->assertFalse($p->isUserAllowed(1, 1)); + $this->assertTrue($p->isUserAllowed(1, 2)); + } +} -- cgit v1.2.3