diff options
author | Frédéric Guillot <fred@kanboard.net> | 2014-09-01 20:40:02 -0800 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2014-09-01 20:40:02 -0800 |
commit | 457e181ffb915e36e5da77317a6c824e10f5d5b3 (patch) | |
tree | eb5443ac4cdbd92278359fcd15d888752c70bc77 /tests/units | |
parent | e6d0658a0eedeb6a641c003d1c492af0f9a7502c (diff) |
Improve task duplication
Diffstat (limited to 'tests/units')
-rw-r--r-- | tests/units/ActionTest.php | 12 | ||||
-rw-r--r-- | tests/units/TaskTest.php | 27 |
2 files changed, 27 insertions, 12 deletions
diff --git a/tests/units/ActionTest.php b/tests/units/ActionTest.php index b6528333..19226449 100644 --- a/tests/units/ActionTest.php +++ b/tests/units/ActionTest.php @@ -142,29 +142,29 @@ class ActionTest extends Base // Our task should have the color red and position=0 $t1 = $task->getById(1); - $this->assertEquals(0, $t1['position']); + $this->assertEquals(1, $t1['position']); $this->assertEquals(1, $t1['is_active']); $this->assertEquals('red', $t1['color_id']); $t1 = $task->getById(2); - $this->assertEquals(1, $t1['position']); + $this->assertEquals(2, $t1['position']); $this->assertEquals(1, $t1['is_active']); $this->assertEquals('yellow', $t1['color_id']); // We move our tasks - $task->movePosition(1, 1, 1); // task #1 to position 1 - $task->movePosition(2, 1, 0); // task #2 to position 0 + $task->movePosition(1, 1, 2); // task #1 to position 2 + $task->movePosition(2, 1, 1); // task #2 to position 1 $this->assertTrue($this->registry->event->isEventTriggered(Task::EVENT_MOVE_POSITION)); // Both tasks should be green $t1 = $task->getById(1); - $this->assertEquals(1, $t1['position']); + $this->assertEquals(2, $t1['position']); $this->assertEquals(1, $t1['is_active']); $this->assertEquals('green', $t1['color_id']); $t1 = $task->getById(2); - $this->assertEquals(0, $t1['position']); + $this->assertEquals(1, $t1['position']); $this->assertEquals(1, $t1['is_active']); $this->assertEquals('green', $t1['color_id']); } diff --git a/tests/units/TaskTest.php b/tests/units/TaskTest.php index 064f30b0..e1a976c1 100644 --- a/tests/units/TaskTest.php +++ b/tests/units/TaskTest.php @@ -132,21 +132,29 @@ class TaskTest extends Base $this->assertEquals('2014-03-05', date('Y-m-d', $t->parseDate('03/05/2014'))); } - public function testDuplicateTask() + public function testDuplicateToTheSameProject() { $t = new Task($this->registry); $p = new Project($this->registry); + $c = new Category($this->registry); // We create a task and a project $this->assertEquals(1, $p->create(array('name' => 'test1'))); + + // Some categories + $this->assertNotFalse($c->create(array('name' => 'Category #1', 'project_id' => 1))); + $this->assertNotFalse($c->create(array('name' => 'Category #2', 'project_id' => 1))); + $this->assertTrue($c->exists(1, 1)); + $this->assertTrue($c->exists(2, 1)); + $this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1, 'category_id' => 2))); $task = $t->getById(1); $this->assertNotEmpty($task); - $this->assertEquals(0, $task['position']); + $this->assertEquals(1, $task['position']); // We duplicate our task - $this->assertEquals(2, $t->duplicate(1)); + $this->assertEquals(2, $t->duplicateSameProject($task)); $this->assertTrue($this->registry->event->isEventTriggered(Task::EVENT_CREATE)); // Check the values of the duplicated task @@ -155,21 +163,26 @@ class TaskTest extends Base $this->assertEquals(Task::STATUS_OPEN, $task['is_active']); $this->assertEquals(1, $task['project_id']); $this->assertEquals(1, $task['owner_id']); - $this->assertEquals(1, $task['position']); $this->assertEquals(2, $task['category_id']); + $this->assertEquals(3, $task['column_id']); + $this->assertEquals(2, $task['position']); } public function testDuplicateToAnotherProject() { $t = new Task($this->registry); $p = new Project($this->registry); + $c = new Category($this->registry); // We create 2 projects $this->assertEquals(1, $p->create(array('name' => 'test1'))); $this->assertEquals(2, $p->create(array('name' => 'test2'))); + $this->assertNotFalse($c->create(array('name' => 'Category #1', 'project_id' => 1))); + $this->assertTrue($c->exists(1, 1)); + // We create a task - $this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1, 'owner_id' => 1, 'category_id' => 1))); + $this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 1, 'category_id' => 1))); $task = $t->getById(1); // We duplicate our task to the 2nd project @@ -181,6 +194,8 @@ class TaskTest extends Base $this->assertNotEmpty($task); $this->assertEquals(1, $task['owner_id']); $this->assertEquals(0, $task['category_id']); + $this->assertEquals(5, $task['column_id']); + $this->assertEquals(1, $task['position']); $this->assertEquals(2, $task['project_id']); $this->assertEquals('test', $task['title']); } @@ -215,7 +230,7 @@ class TaskTest extends Base $this->assertEquals(0, $task['category_id']); $this->assertEquals(2, $task['project_id']); $this->assertEquals(5, $task['column_id']); - $this->assertEquals(0, $task['position']); + $this->assertEquals(1, $task['position']); $this->assertEquals('test', $task['title']); // We allow only one user on the second project |