public function testAverageWithTransitions()
 {
     $transitionModel = new Transition($this->container);
     $taskFinderModel = new TaskFinder($this->container);
     $taskCreationModel = new TaskCreation($this->container);
     $projectModel = new Project($this->container);
     $averageLeadCycleTimeAnalytic = new AverageTimeSpentColumnAnalytic($this->container);
     $now = time();
     $this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
     $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test')));
     $this->assertEquals(2, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test')));
     $this->container['db']->table(Task::TABLE)->eq('id', 1)->update(array('date_completed' => $now + 3600));
     $this->container['db']->table(Task::TABLE)->eq('id', 2)->update(array('date_completed' => $now + 1800));
     foreach (array(1, 2) as $task_id) {
         $task = $taskFinderModel->getById($task_id);
         $task['task_id'] = $task['id'];
         $task['date_moved'] = $now - 900;
         $task['src_column_id'] = 3;
         $task['dst_column_id'] = 1;
         $this->assertTrue($transitionModel->save(1, $task));
     }
     $stats = $averageLeadCycleTimeAnalytic->build(1);
     $expected = array(1 => array('count' => 2, 'time_spent' => 3600 + 1800, 'average' => (int) ((3600 + 1800) / 2), 'title' => 'Backlog'), 2 => array('count' => 0, 'time_spent' => 0, 'average' => 0, 'title' => 'Ready'), 3 => array('count' => 2, 'time_spent' => 1800, 'average' => 900, 'title' => 'Work in progress'), 4 => array('count' => 0, 'time_spent' => 0, 'average' => 0, 'title' => 'Done'));
     $this->assertEquals($expected, $stats);
 }
Esempio n. 2
0
 public function testGetAllByProject()
 {
     $projectModel = new Project($this->container);
     $taskCreationModel = new TaskCreation($this->container);
     $transitionModel = new Transition($this->container);
     $this->assertEquals(1, $projectModel->create(array('name' => 'test')));
     $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test1')));
     $this->assertEquals(2, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test2')));
     $task_event = array('project_id' => 1, 'src_column_id' => 1, 'dst_column_id' => 2, 'date_moved' => time() - 3600);
     $this->assertTrue($transitionModel->save(1, array('task_id' => 1) + $task_event));
     $this->assertTrue($transitionModel->save(1, array('task_id' => 2) + $task_event));
     $task_event = array('project_id' => 1, 'src_column_id' => 2, 'dst_column_id' => 3, 'date_moved' => time() - 1200);
     $this->assertTrue($transitionModel->save(1, array('task_id' => 1) + $task_event));
     $this->assertTrue($transitionModel->save(1, array('task_id' => 2) + $task_event));
     $transitions = $transitionModel->getAllByProjectAndDate(1, date('Y-m-d'), date('Y-m-d'));
     $this->assertCount(4, $transitions);
     $this->assertEquals(2, $transitions[0]['id']);
     $this->assertEquals(1, $transitions[1]['id']);
     $this->assertEquals(2, $transitions[2]['id']);
     $this->assertEquals(1, $transitions[3]['id']);
     $this->assertEquals('test2', $transitions[0]['title']);
     $this->assertEquals('test1', $transitions[1]['title']);
     $this->assertEquals('test2', $transitions[2]['title']);
     $this->assertEquals('test1', $transitions[3]['title']);
     $this->assertEquals('Ready', $transitions[0]['src_column']);
     $this->assertEquals('Ready', $transitions[1]['src_column']);
     $this->assertEquals('Backlog', $transitions[2]['src_column']);
     $this->assertEquals('Backlog', $transitions[3]['src_column']);
     $this->assertEquals('Work in progress', $transitions[0]['dst_column']);
     $this->assertEquals('Work in progress', $transitions[1]['dst_column']);
     $this->assertEquals('Ready', $transitions[2]['dst_column']);
     $this->assertEquals('Ready', $transitions[3]['dst_column']);
     $this->assertEquals('admin', $transitions[0]['username']);
     $this->assertEquals('admin', $transitions[1]['username']);
     $this->assertEquals('admin', $transitions[2]['username']);
     $this->assertEquals('admin', $transitions[3]['username']);
     $this->assertEquals(1200, $transitions[0]['time_spent']);
     $this->assertEquals(1200, $transitions[1]['time_spent']);
     $this->assertEquals(3600, $transitions[2]['time_spent']);
     $this->assertEquals(3600, $transitions[3]['time_spent']);
 }
Esempio n. 3
0
 public function testExport()
 {
     $projectModel = new Project($this->container);
     $taskCreationModel = new TaskCreation($this->container);
     $transitionModel = new Transition($this->container);
     $transitionExportModel = new TransitionExport($this->container);
     $this->assertEquals(1, $projectModel->create(array('name' => 'test')));
     $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test')));
     $task_event = array('project_id' => 1, 'task_id' => 1, 'src_column_id' => 1, 'dst_column_id' => 2, 'date_moved' => time() - 3600);
     $this->assertTrue($transitionModel->save(1, $task_event));
     $export = $transitionExportModel->export(1, date('Y-m-d'), date('Y-m-d'));
     $this->assertCount(2, $export);
     $this->assertEquals(array('Id', 'Task Title', 'Source column', 'Destination column', 'Executer', 'Date', 'Time spent'), $export[0]);
     $this->assertEquals(array(1, 'test', 'Backlog', 'Ready', 'admin', date('m/d/Y H:i', time()), 1.0), $export[1]);
 }