1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
<?php
require_once __DIR__.'/Base.php';
use Model\Project;
use Model\ProjectDailySummary;
use Model\Task;
use Model\TaskCreation;
class ProjectDailySummaryTest extends Base
{
public function testUpdateTotals()
{
$p = new Project($this->container);
$pds = new ProjectDailySummary($this->container);
$tc = new TaskCreation($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($t->close(1));
$this->assertNotFalse($t->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(3, 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('Backlog', $metrics[0][1]);
$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(8, $metrics[3][1]);
$this->assertEquals(30, $metrics[3][2]);
$this->assertEquals(18, $metrics[3][3]);
$this->assertEquals(9, $metrics[3][4]);
}
}
|