public function testUpdateTotals() { $p = new Project($this->container); $pds = new ProjectDailyColumnStats($this->container); $tc = new TaskCreation($this->container); $ts = new TaskStatus($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); $this->assertEquals(0, $pds->countDays(1, date('Y-m-d', strtotime('-2days')), date('Y-m-d'))); for ($i = 0; $i < 10; $i++) { $this->assertNotFalse($tc->create(array('title' => 'Task #' . $i, 'project_id' => 1, 'column_id' => 1))); } for ($i = 0; $i < 5; $i++) { $this->assertNotFalse($tc->create(array('title' => 'Task #' . $i, 'project_id' => 1, 'column_id' => 4))); } $pds->updateTotals(1, date('Y-m-d', strtotime('-2days'))); for ($i = 0; $i < 15; $i++) { $this->assertNotFalse($tc->create(array('title' => 'Task #' . $i, 'project_id' => 1, 'column_id' => 3))); } for ($i = 0; $i < 25; $i++) { $this->assertNotFalse($tc->create(array('title' => 'Task #' . $i, 'project_id' => 1, 'column_id' => 2))); } $pds->updateTotals(1, date('Y-m-d', strtotime('-1 day'))); $this->assertNotFalse($ts->close(1)); $this->assertNotFalse($ts->close(2)); for ($i = 0; $i < 3; $i++) { $this->assertNotFalse($tc->create(array('title' => 'Task #' . $i, 'project_id' => 1, 'column_id' => 3))); } for ($i = 0; $i < 5; $i++) { $this->assertNotFalse($tc->create(array('title' => 'Task #' . $i, 'project_id' => 1, 'column_id' => 2))); } for ($i = 0; $i < 4; $i++) { $this->assertNotFalse($tc->create(array('title' => 'Task #' . $i, 'project_id' => 1, 'column_id' => 4))); } $pds->updateTotals(1, date('Y-m-d')); $this->assertEquals(3, $pds->countDays(1, date('Y-m-d', strtotime('-2days')), date('Y-m-d'))); $metrics = $pds->getAggregatedMetrics(1, date('Y-m-d', strtotime('-2days')), date('Y-m-d')); $this->assertNotEmpty($metrics); $this->assertEquals(4, count($metrics)); $this->assertEquals(5, count($metrics[0])); $this->assertEquals('Date', $metrics[0][0]); $this->assertEquals('Backlog', $metrics[0][1]); $this->assertEquals('Ready', $metrics[0][2]); $this->assertEquals('Work in progress', $metrics[0][3]); $this->assertEquals('Done', $metrics[0][4]); $this->assertEquals(date('Y-m-d', strtotime('-2days')), $metrics[1][0]); $this->assertEquals(10, $metrics[1][1]); $this->assertEquals(0, $metrics[1][2]); $this->assertEquals(0, $metrics[1][3]); $this->assertEquals(5, $metrics[1][4]); $this->assertEquals(date('Y-m-d', strtotime('-1day')), $metrics[2][0]); $this->assertEquals(10, $metrics[2][1]); $this->assertEquals(25, $metrics[2][2]); $this->assertEquals(15, $metrics[2][3]); $this->assertEquals(5, $metrics[2][4]); $this->assertEquals(date('Y-m-d'), $metrics[3][0]); $this->assertEquals(10, $metrics[3][1]); $this->assertEquals(30, $metrics[3][2]); $this->assertEquals(18, $metrics[3][3]); $this->assertEquals(9, $metrics[3][4]); }
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']); } }
public function testGetTaskProgression() { $t = new Task($this->container); $ts = new TaskStatus($this->container); $tp = new TaskPosition($this->container); $tc = new TaskCreation($this->container); $tf = new TaskFinder($this->container); $p = new Project($this->container); $b = new Board($this->container); $this->assertEquals(1, $p->create(array('name' => 'Project #1'))); $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'column_id' => 1))); $this->assertEquals(0, $t->getProgress($tf->getById(1), $b->getColumnsList(1))); $this->assertTrue($tp->movePosition(1, 1, 2, 1)); $this->assertEquals(25, $t->getProgress($tf->getById(1), $b->getColumnsList(1))); $this->assertTrue($tp->movePosition(1, 1, 3, 1)); $this->assertEquals(50, $t->getProgress($tf->getById(1), $b->getColumnsList(1))); $this->assertTrue($tp->movePosition(1, 1, 4, 1)); $this->assertEquals(75, $t->getProgress($tf->getById(1), $b->getColumnsList(1))); $this->assertTrue($ts->close(1)); $this->assertEquals(100, $t->getProgress($tf->getById(1), $b->getColumnsList(1))); }
public function testStatus() { $tc = new TaskCreation($this->container); $tf = new TaskFinder($this->container); $ts = new TaskStatus($this->container); $p = new Project($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1))); // The task must be open $this->assertTrue($ts->isOpen(1)); $task = $tf->getById(1); $this->assertNotEmpty($task); $this->assertEquals(Task::STATUS_OPEN, $task['is_active']); $this->assertEquals(0, $task['date_completed']); $this->assertEquals(time(), $task['date_modification']); // We close the task $this->assertTrue($ts->close(1)); $this->assertTrue($ts->isClosed(1)); $task = $tf->getById(1); $this->assertNotEmpty($task); $this->assertEquals(Task::STATUS_CLOSED, $task['is_active']); $this->assertEquals(time(), $task['date_completed']); $this->assertEquals(time(), $task['date_modification']); $this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_CLOSE)); // We open the task again $this->assertTrue($ts->open(1)); $this->assertTrue($ts->isOpen(1)); $task = $tf->getById(1); $this->assertNotEmpty($task); $this->assertEquals(Task::STATUS_OPEN, $task['is_active']); $this->assertEquals(0, $task['date_completed']); $this->assertEquals(time(), $task['date_modification']); $this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_OPEN)); }
public function testStatus() { $tc = new TaskCreation($this->container); $tf = new TaskFinder($this->container); $ts = new TaskStatus($this->container); $p = new Project($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1))); // The task must be open $this->assertTrue($ts->isOpen(1)); $task = $tf->getById(1); $this->assertNotEmpty($task); $this->assertEquals(Task::STATUS_OPEN, $task['is_active']); $this->assertEquals(0, $task['date_completed']); $this->assertEquals(time(), $task['date_modification']); // We close the task $this->container['dispatcher']->addListener(Task::EVENT_CLOSE, array($this, 'onTaskClose')); $this->container['dispatcher']->addListener(Task::EVENT_OPEN, array($this, 'onTaskOpen')); $this->assertTrue($ts->close(1)); $this->assertTrue($ts->isClosed(1)); $task = $tf->getById(1); $this->assertNotEmpty($task); $this->assertEquals(Task::STATUS_CLOSED, $task['is_active']); $this->assertEquals(time(), $task['date_completed']); $this->assertEquals(time(), $task['date_modification']); // We open the task again $this->assertTrue($ts->open(1)); $this->assertTrue($ts->isOpen(1)); $task = $tf->getById(1); $this->assertNotEmpty($task); $this->assertEquals(Task::STATUS_OPEN, $task['is_active']); $this->assertEquals(0, $task['date_completed']); $this->assertEquals(time(), $task['date_modification']); $called = $this->container['dispatcher']->getCalledListeners(); $this->assertArrayHasKey('task.close.TaskStatusTest::onTaskClose', $called); $this->assertArrayHasKey('task.open.TaskStatusTest::onTaskOpen', $called); }
#!/usr/bin/env php <?php require __DIR__ . '/../app/common.php'; use Model\ProjectDailyColumnStats; use Model\TaskCreation; use Model\TaskStatus; $pds = new ProjectDailyColumnStats($container); $taskCreation = new TaskCreation($container); $taskStatus = new TaskStatus($container); for ($i = 1; $i <= 15; $i++) { $task = array('title' => 'Task #' . $i, 'project_id' => 1, 'column_id' => rand(1, 4), 'score' => rand(1, 21)); $taskCreation->create($task); } $pds->updateTotals(1, date('Y-m-d', strtotime('-7 days'))); $taskStatus->close(1); $pds->updateTotals(1, date('Y-m-d', strtotime('-6 days'))); $taskStatus->close(2); $taskStatus->close(3); $pds->updateTotals(1, date('Y-m-d', strtotime('-5 days'))); $taskStatus->close(4); $pds->updateTotals(1, date('Y-m-d', strtotime('-4 days'))); $taskStatus->close(5); $pds->updateTotals(1, date('Y-m-d', strtotime('-3 days'))); $taskStatus->close(6); $taskStatus->close(7); $taskStatus->close(8); $pds->updateTotals(1, date('Y-m-d', strtotime('-2 days'))); $taskStatus->close(9); $taskStatus->close(10); $pds->updateTotals(1, date('Y-m-d', strtotime('-2 days'))); $taskStatus->close(12);