diff options
author | Frédéric Guillot <fred@kanboard.net> | 2015-01-02 21:11:19 -0500 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2015-01-02 21:11:19 -0500 |
commit | 45c95d74fc2115fe4cc7214553c0927d3ce9df8d (patch) | |
tree | 5135be8a33752cce4f1b457a5c379e02aaa65038 /tests | |
parent | 3076ba22dd8346725b4e1ad757532c00df5b18d9 (diff) |
Various fixes and improvements
Diffstat (limited to 'tests')
-rw-r--r-- | tests/functionals/ApiTest.php | 8 | ||||
-rw-r--r-- | tests/units/ProjectDuplicateTest.php | 38 | ||||
-rw-r--r-- | tests/units/TaskCreationTest.php | 12 |
3 files changed, 50 insertions, 8 deletions
diff --git a/tests/functionals/ApiTest.php b/tests/functionals/ApiTest.php index eb1e0cd1..f778d1ca 100644 --- a/tests/functionals/ApiTest.php +++ b/tests/functionals/ApiTest.php @@ -26,10 +26,12 @@ class Api extends PHPUnit_Framework_TestCase } $service = new ServiceProvider\DatabaseProvider; - $service->getInstance(); - $pdo->exec("UPDATE settings SET value='".API_KEY."' WHERE option='api_token'"); - $pdo->exec("UPDATE settings SET value='Europe/Paris' WHERE option='application_timezone'"); + $db = $service->getInstance(); + $db->table('settings')->eq('option', 'api_token')->update(array('value' => API_KEY)); + $db->table('settings')->eq('option', 'application_timezone')->update(array('value' => 'Europe/Paris')); + $db->closeConnection(); + $pdo = null; } diff --git a/tests/units/ProjectDuplicateTest.php b/tests/units/ProjectDuplicateTest.php index 973a0c32..161bbe20 100644 --- a/tests/units/ProjectDuplicateTest.php +++ b/tests/units/ProjectDuplicateTest.php @@ -79,6 +79,40 @@ class ProjectDuplicationTest extends Base $this->assertEquals('C3', $categories[2]['name']); } - // TODO: test users - // TODO: test actions + public function testCloneProjectWithUsers() + { + $p = new Project($this->container); + $c = new Category($this->container); + $pp = new ProjectPermission($this->container); + $u = new User($this->container); + + $this->assertEquals(2, $u->create(array('username' => 'unittest1', 'password' => 'unittest'))); + $this->assertEquals(3, $u->create(array('username' => 'unittest2', 'password' => 'unittest'))); + $this->assertEquals(4, $u->create(array('username' => 'unittest3', 'password' => 'unittest'))); + + $this->assertEquals(1, $p->create(array('name' => 'P1'))); + $this->assertTrue($pp->addMember(1, 2)); + $this->assertTrue($pp->addMember(1, 4)); + $this->assertTrue($pp->addManager(1, 3)); + $this->assertTrue($pp->isMember(1, 2)); + $this->assertTrue($pp->isMember(1, 3)); + $this->assertTrue($pp->isMember(1, 4)); + $this->assertFalse($pp->isManager(1, 2)); + $this->assertTrue($pp->isManager(1, 3)); + $this->assertFalse($pp->isManager(1, 4)); + + $this->assertEquals(2, $p->duplicate(1)); + + $project = $p->getById(2); + $this->assertNotEmpty($project); + $this->assertEquals('P1 (Clone)', $project['name']); + + $this->assertEquals(3, count($pp->getMembers(2))); + $this->assertTrue($pp->isMember(2, 2)); + $this->assertTrue($pp->isMember(2, 3)); + $this->assertTrue($pp->isMember(2, 4)); + $this->assertFalse($pp->isManager(2, 2)); + $this->assertTrue($pp->isManager(2, 3)); + $this->assertFalse($pp->isManager(2, 4)); + } } diff --git a/tests/units/TaskCreationTest.php b/tests/units/TaskCreationTest.php index 41a3f276..bdb0a79d 100644 --- a/tests/units/TaskCreationTest.php +++ b/tests/units/TaskCreationTest.php @@ -48,11 +48,17 @@ class TaskCreationTest extends Base $this->container['dispatcher']->addListener(Task::EVENT_CREATE, function() {}); $this->assertEquals(1, $p->create(array('name' => 'test'))); - $this->assertEquals(0, $tc->create(array('project_id' => 1))); + $this->assertEquals(1, $tc->create(array('project_id' => 1))); $called = $this->container['dispatcher']->getCalledListeners(); - $this->assertArrayNotHasKey(Task::EVENT_CREATE_UPDATE.'.closure', $called); - $this->assertArrayNotHasKey(Task::EVENT_CREATE.'.closure', $called); + $this->assertArrayHasKey(Task::EVENT_CREATE_UPDATE.'.closure', $called); + $this->assertArrayHasKey(Task::EVENT_CREATE.'.closure', $called); + + $task = $tf->getById(1); + $this->assertNotEmpty($task); + $this->assertEquals(1, $task['id']); + $this->assertEquals('Untitled', $task['title']); + $this->assertEquals(1, $task['project_id']); } public function testMinimum() |