summaryrefslogtreecommitdiff
path: root/tests/units/Model
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-11-21 18:41:15 -0500
committerFrederic Guillot <fred@kanboard.net>2015-11-21 18:41:15 -0500
commit0a7370b9e5652918ad9386baa81cc12627069755 (patch)
tree95b3fab02e56f26c036e0d8bb0c761d81798c1c1 /tests/units/Model
parent9deeaa4ef1e74531f5f7d99c5de423303ddda7ed (diff)
Remove workaround for 'INSERT ON DUPLICATE KEY UPDATE...'
Diffstat (limited to 'tests/units/Model')
-rw-r--r--tests/units/Model/ProjectDailyStatsTest.php45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/units/Model/ProjectDailyStatsTest.php b/tests/units/Model/ProjectDailyStatsTest.php
new file mode 100644
index 00000000..c17017c9
--- /dev/null
+++ b/tests/units/Model/ProjectDailyStatsTest.php
@@ -0,0 +1,45 @@
+<?php
+
+require_once __DIR__.'/../Base.php';
+
+use Kanboard\Model\Project;
+use Kanboard\Model\ProjectDailyStats;
+use Kanboard\Model\Task;
+use Kanboard\Model\TaskCreation;
+use Kanboard\Model\TaskStatus;
+
+class ProjectDailyStatsTest extends Base
+{
+ public function testUpdateTotals()
+ {
+ $p = new Project($this->container);
+ $pds = new ProjectDailyStats($this->container);
+ $tc = new TaskCreation($this->container);
+ $ts = new TaskStatus($this->container);
+
+ $this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
+
+ $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'date_started' => strtotime('-1 day'))));
+ $this->assertEquals(2, $tc->create(array('title' => 'Task #1', 'project_id' => 1)));
+ $pds->updateTotals(1, date('Y-m-d', strtotime('-1 day')));
+
+ $this->assertTrue($ts->close(1));
+ $pds->updateTotals(1, date('Y-m-d'));
+
+ $metrics = $pds->getRawMetrics(1, date('Y-m-d', strtotime('-1days')), date('Y-m-d'));
+ $expected = array(
+ array(
+ 'day' => '2015-11-20',
+ 'avg_lead_time' => 0,
+ 'avg_cycle_time' => 43200,
+ ),
+ array(
+ 'day' => '2015-11-21',
+ 'avg_lead_time' => 0,
+ 'avg_cycle_time' => 43200,
+ )
+ );
+
+ $this->assertEquals($expected, $metrics);
+ }
+}