From 7749b8ed569f6d27b0bb2ed4c2040e8b61ed4422 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Sun, 9 Mar 2014 23:21:23 -0400 Subject: Automatic actions --- tests/ProjectTest.php | 46 +++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 17 deletions(-) (limited to 'tests/ProjectTest.php') diff --git a/tests/ProjectTest.php b/tests/ProjectTest.php index e6725b99..c04c7ff0 100644 --- a/tests/ProjectTest.php +++ b/tests/ProjectTest.php @@ -1,24 +1,19 @@ db, $this->event); + $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); $this->assertNotEmpty($p->getById(1)); } @@ -26,10 +21,10 @@ class ProjectTest extends PHPUnit_Framework_TestCase public function testAllowEverybody() { // We create a regular user - $user = new User; + $user = new User($this->db, $this->event); $user->create(array('username' => 'unittest', 'password' => 'unittest')); - $p = new Project; + $p = new Project($this->db, $this->event); $this->assertEmpty($p->getAllowedUsers(1)); // Nobody is specified for the given project $this->assertTrue($p->isUserAllowed(1, 1)); // Everybody should be allowed $this->assertTrue($p->isUserAllowed(1, 2)); // Everybody should be allowed @@ -37,7 +32,12 @@ class ProjectTest extends PHPUnit_Framework_TestCase public function testAllowUser() { - $p = new Project; + $p = new Project($this->db, $this->event); + $user = new User($this->db, $this->event); + $user->create(array('username' => 'unittest', 'password' => 'unittest')); + + // We create a project + $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); // We allow the admin user $this->assertTrue($p->allowUser(1, 1)); @@ -58,7 +58,13 @@ class ProjectTest extends PHPUnit_Framework_TestCase public function testRevokeUser() { - $p = new Project; + $p = new Project($this->db, $this->event); + + $user = new User($this->db, $this->event); + $user->create(array('username' => 'unittest', 'password' => 'unittest')); + + // We create a project + $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); // We revoke our admin user $this->assertTrue($p->revokeUser(1, 1)); @@ -107,7 +113,13 @@ class ProjectTest extends PHPUnit_Framework_TestCase public function testUsersList() { - $p = new Project; + $p = new Project($this->db, $this->event); + + $user = new User($this->db, $this->event); + $user->create(array('username' => 'unittest', 'password' => 'unittest')); + + // We create project + $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); // No restriction, we should have everybody $this->assertEquals( -- cgit v1.2.3