public function testMoveDown() { $tc = new TaskCreation($this->container); $s = new Subtask($this->container); $p = new Project($this->container); $this->assertEquals(1, $p->create(array('name' => 'test1'))); $this->assertEquals(1, $tc->create(array('title' => 'test 1', 'project_id' => 1))); $this->assertEquals(1, $s->create(array('title' => 'subtask #1', 'task_id' => 1))); $this->assertEquals(2, $s->create(array('title' => 'subtask #2', 'task_id' => 1))); $this->assertEquals(3, $s->create(array('title' => 'subtask #3', 'task_id' => 1))); // Move down #1 $this->assertTrue($s->moveDown(1, 1)); // Check positions $subtask = $s->getById(1); $this->assertNotEmpty($subtask); $this->assertEquals(2, $subtask['position']); $subtask = $s->getById(2); $this->assertNotEmpty($subtask); $this->assertEquals(1, $subtask['position']); $subtask = $s->getById(3); $this->assertNotEmpty($subtask); $this->assertEquals(3, $subtask['position']); // We can't move down #3 $this->assertFalse($s->moveDown(1, 3)); // Test remove $this->assertTrue($s->remove(1)); $this->assertTrue($s->moveDown(1, 2)); // Check positions $subtask = $s->getById(1); $this->assertEmpty($subtask); $subtask = $s->getById(2); $this->assertNotEmpty($subtask); $this->assertEquals(2, $subtask['position']); $subtask = $s->getById(3); $this->assertNotEmpty($subtask); $this->assertEquals(1, $subtask['position']); }
public function testUpdateTaskTimeTracking() { $tf = new TaskFinder($this->container); $tc = new TaskCreation($this->container); $s = new Subtask($this->container); $st = new SubtaskTimeTracking($this->container); $p = new Project($this->container); $this->assertEquals(1, $p->create(array('name' => 'test1'))); $this->assertEquals(1, $tc->create(array('title' => 'test 1', 'project_id' => 1))); $this->assertEquals(2, $tc->create(array('title' => 'test 2', 'project_id' => 1, 'time_estimated' => 1.5, 'time_spent' => 0.5))); $this->assertEquals(3, $tc->create(array('title' => 'test 3', 'project_id' => 1, 'time_estimated' => 4, 'time_spent' => 2))); $this->assertEquals(1, $s->create(array('title' => 'subtask #1', 'task_id' => 1, 'time_spent' => 2.2))); $this->assertEquals(2, $s->create(array('title' => 'subtask #2', 'task_id' => 1, 'time_estimated' => 1))); $this->assertEquals(3, $s->create(array('title' => 'subtask #3', 'task_id' => 2, 'time_spent' => 3.4))); $this->assertEquals(4, $s->create(array('title' => 'subtask #4', 'task_id' => 2, 'time_estimated' => 1.25))); $this->assertEquals(5, $s->create(array('title' => 'subtask #5', 'task_id' => 3, 'time_spent' => 8))); $st->updateTaskTimeTracking(1); $st->updateTaskTimeTracking(2); $st->updateTaskTimeTracking(3); $task = $tf->getById(1); $this->assertNotEmpty($task); $this->assertEquals(2.2, $task['time_spent'], 'Total spent', 0.01); $this->assertEquals(1, $task['time_estimated'], 'Total estimated', 0.01); $task = $tf->getById(2); $this->assertNotEmpty($task); $this->assertEquals(3.4, $task['time_spent'], 'Total spent', 0.01); $this->assertEquals(1.25, $task['time_estimated'], 'Total estimated', 0.01); $task = $tf->getById(3); $this->assertNotEmpty($task); $this->assertEquals(0, $task['time_estimated']); $this->assertEquals(8, $task['time_spent']); $this->assertTrue($s->remove(3)); $this->assertTrue($s->remove(4)); $st->updateTaskTimeTracking(2); $task = $tf->getById(2); $this->assertNotEmpty($task); $this->assertEquals(0, $task['time_estimated']); $this->assertEquals(0, $task['time_spent']); }