diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-01-23 12:04:10 -0500 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-01-23 12:04:10 -0500 |
commit | 0448fdc56b9d7c58ac78d8375447c59b68702562 (patch) | |
tree | 301715e61c2c148b7e1059e3f0b989cf20d65a9b /tests | |
parent | 94207cf8ea41132fd7279ab08845677542eb3c9f (diff) |
Fix bug: Unable to unassign a task from the API
Diffstat (limited to 'tests')
-rw-r--r-- | tests/integration/TaskTest.php | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/integration/TaskTest.php b/tests/integration/TaskTest.php new file mode 100644 index 00000000..20da12bd --- /dev/null +++ b/tests/integration/TaskTest.php @@ -0,0 +1,58 @@ +<?php + +require_once __DIR__.'/Base.php'; + +class TaskTest extends Base +{ + public function testChangeAssigneeToAssignableUser() + { + $project_id = $this->app->createProject('My project'); + $this->assertNotFalse($project_id); + + $user_id = $this->app->createUser('user0', 'password'); + $this->assertNotFalse($user_id); + + $this->assertTrue($this->app->addProjectUser($project_id, $user_id, 'project-member')); + + $task_id = $this->app->createTask(array('project_id' => $project_id, 'title' => 'My task')); + $this->assertNotFalse($task_id); + + $this->assertTrue($this->app->updateTask(array('id' => $task_id, 'project_id' => $project_id, 'owner_id' => $user_id))); + + $task = $this->app->getTask($task_id); + $this->assertEquals($user_id, $task['owner_id']); + } + + public function testChangeAssigneeToNotAssignableUser() + { + $project_id = $this->app->createProject('My project'); + $this->assertNotFalse($project_id); + + $task_id = $this->app->createTask(array('project_id' => $project_id, 'title' => 'My task')); + $this->assertNotFalse($task_id); + + $this->assertFalse($this->app->updateTask(array('id' => $task_id, 'project_id' => $project_id, 'owner_id' => 1))); + + $task = $this->app->getTask($task_id); + $this->assertEquals(0, $task['owner_id']); + } + + public function testChangeAssigneeToNobody() + { + $project_id = $this->app->createProject('My project'); + $this->assertNotFalse($project_id); + + $user_id = $this->app->createUser('user1', 'password'); + $this->assertNotFalse($user_id); + + $this->assertTrue($this->app->addProjectUser($project_id, $user_id, 'project-member')); + + $task_id = $this->app->createTask(array('project_id' => $project_id, 'title' => 'My task', 'owner_id' => $user_id)); + $this->assertNotFalse($task_id); + + $this->assertTrue($this->app->updateTask(array('id' => $task_id, 'project_id' => $project_id, 'owner_id' => 0))); + + $task = $this->app->getTask($task_id); + $this->assertEquals(0, $task['owner_id']); + } +} |