コード例 #1
0
 public function testGetTimerStatus()
 {
     $tc = new TaskCreation($this->container);
     $s = new Subtask($this->container);
     $st = new SubtaskTimeTracking($this->container);
     $p = new Project($this->container);
     $ss = new Session();
     $ss['user'] = array('id' => 1);
     $this->assertEquals(1, $p->create(array('name' => 'test1')));
     $this->assertEquals(1, $tc->create(array('title' => 'test 1', 'project_id' => 1, 'column_id' => 1, 'owner_id' => 1)));
     $this->assertEquals(1, $s->create(array('title' => 'subtask #1', 'task_id' => 1, 'user_id' => 1)));
     // Nothing started
     $subtasks = $s->getAll(1);
     $this->assertNotEmpty($subtasks);
     $this->assertEquals(0, $subtasks[0]['timer_start_date']);
     $this->assertFalse($subtasks[0]['is_timer_started']);
     $subtask = $s->getbyId(1, true);
     $this->assertNotEmpty($subtask);
     $this->assertEquals(0, $subtask['timer_start_date']);
     $this->assertFalse($subtask['is_timer_started']);
     // Start the clock
     $this->assertTrue($st->logStartTime(1, 1));
     $subtasks = $s->getAll(1);
     $this->assertNotEmpty($subtasks);
     $this->assertEquals(time(), $subtasks[0]['timer_start_date'], '', 3);
     $this->assertTrue($subtasks[0]['is_timer_started']);
     $subtask = $s->getbyId(1, true);
     $this->assertNotEmpty($subtask);
     $this->assertEquals(time(), $subtask['timer_start_date'], '', 3);
     $this->assertTrue($subtask['is_timer_started']);
     // Stop the clock
     $this->assertTrue($st->logEndTime(1, 1));
     $subtasks = $s->getAll(1);
     $this->assertNotEmpty($subtasks);
     $this->assertEquals(0, $subtasks[0]['timer_start_date']);
     $this->assertFalse($subtasks[0]['is_timer_started']);
     $subtask = $s->getbyId(1, true);
     $this->assertNotEmpty($subtask);
     $this->assertEquals(0, $subtask['timer_start_date']);
     $this->assertFalse($subtask['is_timer_started']);
 }
コード例 #2
0
ファイル: TaskStatusTest.php プロジェクト: phpCedu/kanboard
 public function testThatAllSubtasksAreClosed()
 {
     $ts = new TaskStatus($this->container);
     $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->assertTrue($ts->close(1));
     $subtasks = $s->getAll(1);
     $this->assertNotEmpty($subtasks);
     foreach ($subtasks as $subtask) {
         $this->assertEquals(Subtask::STATUS_DONE, $subtask['status']);
     }
 }
コード例 #3
0
ファイル: SubtaskTest.php プロジェクト: perburn/kanboard
 public function testChangePosition()
 {
     $taskCreationModel = new TaskCreation($this->container);
     $subtaskModel = new Subtask($this->container);
     $projectModel = new Project($this->container);
     $this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
     $this->assertEquals(1, $taskCreationModel->create(array('title' => 'test 1', 'project_id' => 1)));
     $this->assertEquals(1, $subtaskModel->create(array('title' => 'subtask #1', 'task_id' => 1)));
     $this->assertEquals(2, $subtaskModel->create(array('title' => 'subtask #2', 'task_id' => 1)));
     $this->assertEquals(3, $subtaskModel->create(array('title' => 'subtask #3', 'task_id' => 1)));
     $subtasks = $subtaskModel->getAll(1);
     $this->assertEquals(1, $subtasks[0]['position']);
     $this->assertEquals(1, $subtasks[0]['id']);
     $this->assertEquals(2, $subtasks[1]['position']);
     $this->assertEquals(2, $subtasks[1]['id']);
     $this->assertEquals(3, $subtasks[2]['position']);
     $this->assertEquals(3, $subtasks[2]['id']);
     $this->assertTrue($subtaskModel->changePosition(1, 3, 2));
     $subtasks = $subtaskModel->getAll(1);
     $this->assertEquals(1, $subtasks[0]['position']);
     $this->assertEquals(1, $subtasks[0]['id']);
     $this->assertEquals(2, $subtasks[1]['position']);
     $this->assertEquals(3, $subtasks[1]['id']);
     $this->assertEquals(3, $subtasks[2]['position']);
     $this->assertEquals(2, $subtasks[2]['id']);
     $this->assertTrue($subtaskModel->changePosition(1, 2, 1));
     $subtasks = $subtaskModel->getAll(1);
     $this->assertEquals(1, $subtasks[0]['position']);
     $this->assertEquals(2, $subtasks[0]['id']);
     $this->assertEquals(2, $subtasks[1]['position']);
     $this->assertEquals(1, $subtasks[1]['id']);
     $this->assertEquals(3, $subtasks[2]['position']);
     $this->assertEquals(3, $subtasks[2]['id']);
     $this->assertTrue($subtaskModel->changePosition(1, 2, 2));
     $subtasks = $subtaskModel->getAll(1);
     $this->assertEquals(1, $subtasks[0]['position']);
     $this->assertEquals(1, $subtasks[0]['id']);
     $this->assertEquals(2, $subtasks[1]['position']);
     $this->assertEquals(2, $subtasks[1]['id']);
     $this->assertEquals(3, $subtasks[2]['position']);
     $this->assertEquals(3, $subtasks[2]['id']);
     $this->assertTrue($subtaskModel->changePosition(1, 1, 3));
     $subtasks = $subtaskModel->getAll(1);
     $this->assertEquals(1, $subtasks[0]['position']);
     $this->assertEquals(2, $subtasks[0]['id']);
     $this->assertEquals(2, $subtasks[1]['position']);
     $this->assertEquals(3, $subtasks[1]['id']);
     $this->assertEquals(3, $subtasks[2]['position']);
     $this->assertEquals(1, $subtasks[2]['id']);
     $this->assertFalse($subtaskModel->changePosition(1, 2, 0));
     $this->assertFalse($subtaskModel->changePosition(1, 2, 4));
 }
コード例 #4
0
 public function testDuplicate()
 {
     $tc = new TaskCreation($this->container);
     $s = new Subtask($this->container);
     $p = new Project($this->container);
     // We create a project
     $this->assertEquals(1, $p->create(array('name' => 'test1')));
     // We create 2 tasks
     $this->assertEquals(1, $tc->create(array('title' => 'test 1', 'project_id' => 1, 'column_id' => 1, 'owner_id' => 1)));
     $this->assertEquals(2, $tc->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, 'another_subtask' => 'on')));
     $this->assertEquals(2, $s->create(array('title' => 'subtask #2', 'task_id' => 1, 'time_estimated' => '', 'time_spent' => '', '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']);
     $this->assertEquals(1, $subtasks[0]['position']);
     $this->assertEquals(2, $subtasks[1]['position']);
 }