summaryrefslogtreecommitdiff
path: root/tests/units/Analytic
diff options
context:
space:
mode:
Diffstat (limited to 'tests/units/Analytic')
-rw-r--r--tests/units/Analytic/AverageLeadCycleTimeAnalyticTest.php13
-rw-r--r--tests/units/Analytic/AverageTimeSpentColumnAnalyticTest.php101
2 files changed, 48 insertions, 66 deletions
diff --git a/tests/units/Analytic/AverageLeadCycleTimeAnalyticTest.php b/tests/units/Analytic/AverageLeadCycleTimeAnalyticTest.php
index 9c445dca..b8faec6c 100644
--- a/tests/units/Analytic/AverageLeadCycleTimeAnalyticTest.php
+++ b/tests/units/Analytic/AverageLeadCycleTimeAnalyticTest.php
@@ -37,15 +37,12 @@ class AverageLeadCycleTimeAnalyticTest extends Base
$this->container['db']->table(Task::TABLE)->eq('id', 4)->update(array('date_completed' => $now + 2 * 3600));
$stats = $averageLeadCycleTimeAnalytic->build(1);
- $expected = array(
- 'count' => 4,
- 'total_lead_time' => 3600 + 1800 + 3600 + 2*3600,
- 'total_cycle_time' => 1800 + 900,
- 'avg_lead_time' => (3600 + 1800 + 3600 + 2*3600) / 4,
- 'avg_cycle_time' => (1800 + 900) / 4,
- );
- $this->assertEquals($expected, $stats);
+ $this->assertEquals(4, $stats['count']);
+ $this->assertEquals(3600 + 1800 + 3600 + 2*3600, $stats['total_lead_time'], '', 5);
+ $this->assertEquals(1800 + 900, $stats['total_cycle_time'], '', 5);
+ $this->assertEquals((3600 + 1800 + 3600 + 2*3600) / 4, $stats['avg_lead_time'], '', 5);
+ $this->assertEquals((1800 + 900) / 4, $stats['avg_cycle_time'], '', 5);
}
public function testBuildWithNoTasks()
diff --git a/tests/units/Analytic/AverageTimeSpentColumnAnalyticTest.php b/tests/units/Analytic/AverageTimeSpentColumnAnalyticTest.php
index 75cb181d..4e01bfa9 100644
--- a/tests/units/Analytic/AverageTimeSpentColumnAnalyticTest.php
+++ b/tests/units/Analytic/AverageTimeSpentColumnAnalyticTest.php
@@ -16,45 +16,38 @@ class AverageTimeSpentColumnAnalyticTest extends Base
$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')));
+ $now = time();
+
$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));
$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' => 0,
- 'time_spent' => 0,
- 'average' => 0,
- 'title' => 'Work in progress',
- ),
- 4 => array(
- 'count' => 0,
- 'time_spent' => 0,
- 'average' => 0,
- 'title' => 'Done',
- )
- );
-
- $this->assertEquals($expected, $stats);
+
+ $this->assertEquals(2, $stats[1]['count']);
+ $this->assertEquals(3600+1800, $stats[1]['time_spent'], '', 3);
+ $this->assertEquals((int) ((3600+1800)/2), $stats[1]['average'], '', 3);
+ $this->assertEquals('Backlog', $stats[1]['title']);
+
+ $this->assertEquals(0, $stats[2]['count']);
+ $this->assertEquals(0, $stats[2]['time_spent'], '', 3);
+ $this->assertEquals(0, $stats[2]['average'], '', 3);
+ $this->assertEquals('Ready', $stats[2]['title']);
+
+ $this->assertEquals(0, $stats[3]['count']);
+ $this->assertEquals(0, $stats[3]['time_spent'], '', 3);
+ $this->assertEquals(0, $stats[3]['average'], '', 3);
+ $this->assertEquals('Work in progress', $stats[3]['title']);
+
+ $this->assertEquals(0, $stats[4]['count']);
+ $this->assertEquals(0, $stats[4]['time_spent'], '', 3);
+ $this->assertEquals(0, $stats[4]['average'], '', 3);
+ $this->assertEquals('Done', $stats[4]['title']);
}
public function testAverageWithTransitions()
@@ -64,13 +57,13 @@ class AverageTimeSpentColumnAnalyticTest extends Base
$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')));
+ $now = time();
$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));
@@ -84,33 +77,25 @@ class AverageTimeSpentColumnAnalyticTest extends Base
}
$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);
+
+ $this->assertEquals(2, $stats[1]['count']);
+ $this->assertEquals(3600+1800, $stats[1]['time_spent'], '', 3);
+ $this->assertEquals((int) ((3600+1800)/2), $stats[1]['average'], '', 3);
+ $this->assertEquals('Backlog', $stats[1]['title']);
+
+ $this->assertEquals(0, $stats[2]['count']);
+ $this->assertEquals(0, $stats[2]['time_spent'], '', 3);
+ $this->assertEquals(0, $stats[2]['average'], '', 3);
+ $this->assertEquals('Ready', $stats[2]['title']);
+
+ $this->assertEquals(2, $stats[3]['count']);
+ $this->assertEquals(1800, $stats[3]['time_spent'], '', 3);
+ $this->assertEquals(900, $stats[3]['average'], '', 3);
+ $this->assertEquals('Work in progress', $stats[3]['title']);
+
+ $this->assertEquals(0, $stats[4]['count']);
+ $this->assertEquals(0, $stats[4]['time_spent'], '', 3);
+ $this->assertEquals(0, $stats[4]['average'], '', 3);
+ $this->assertEquals('Done', $stats[4]['title']);
}
}