diff options
Diffstat (limited to 'tests/units/SubtaskTest.php')
-rw-r--r-- | tests/units/SubtaskTest.php | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/units/SubtaskTest.php b/tests/units/SubtaskTest.php new file mode 100644 index 00000000..a74ee60a --- /dev/null +++ b/tests/units/SubtaskTest.php @@ -0,0 +1,56 @@ +<?php + +require_once __DIR__.'/Base.php'; + +use Model\Task; +use Model\SubTask; +use Model\Project; +use Model\Category; +use Model\User; + +class SubTaskTest extends Base +{ + public function testDuplicate() + { + $t = new Task($this->registry); + $s = new SubTask($this->registry); + $p = new Project($this->registry); + + // We create a project + $this->assertEquals(1, $p->create(array('name' => 'test1'))); + + // We create 2 tasks + $this->assertEquals(1, $t->create(array('title' => 'test 1', 'project_id' => 1, 'column_id' => 1, 'owner_id' => 1))); + $this->assertEquals(2, $t->create(array('title' => 'test 2', 'project_id' => 1, 'column_id' => 1, 'owner_id' => 0))); + + // We create many subtasks for the first task + $this->assertEquals(1, $s->create(array('title' => 'subtask #1', 'task_id' => 1, 'time_estimated' => 5, 'time_spent' => 3, 'status' => 1))); + $this->assertEquals(2, $s->create(array('title' => 'subtask #2', 'task_id' => 1, 'time_estimated' => 0, 'time_spent' => 0, 'status' => 2, 'user_id' => 1))); + + // We duplicate our subtasks + $this->assertTrue($s->duplicate(1, 2)); + $subtasks = $s->getAll(2); + + $this->assertNotFalse($subtasks); + $this->assertNotEmpty($subtasks); + $this->assertEquals(2, count($subtasks)); + + $this->assertEquals('subtask #1', $subtasks[0]['title']); + $this->assertEquals('subtask #2', $subtasks[1]['title']); + + $this->assertEquals(2, $subtasks[0]['task_id']); + $this->assertEquals(2, $subtasks[1]['task_id']); + + $this->assertEquals(5, $subtasks[0]['time_estimated']); + $this->assertEquals(0, $subtasks[1]['time_estimated']); + + $this->assertEquals(0, $subtasks[0]['time_spent']); + $this->assertEquals(0, $subtasks[1]['time_spent']); + + $this->assertEquals(0, $subtasks[0]['status']); + $this->assertEquals(0, $subtasks[1]['status']); + + $this->assertEquals(0, $subtasks[0]['user_id']); + $this->assertEquals(0, $subtasks[1]['user_id']); + } +} |