summaryrefslogtreecommitdiff
path: root/tests/units/Job
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-07-23 20:30:06 -0400
committerFrederic Guillot <fred@kanboard.net>2016-07-23 20:30:06 -0400
commitadb5023cfc075ce5d6f73a4ba5b4ab51f6c500c0 (patch)
tree4333191b7f866ea5f5864df9173e61aa7e0d58b5 /tests/units/Job
parent8e6e335c9d99ff710ecd70dff293f15a25bf9a98 (diff)
Add unit test for ProjectMetricJob
Diffstat (limited to 'tests/units/Job')
-rw-r--r--tests/units/Job/ProjectMetricJobTest.php47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/units/Job/ProjectMetricJobTest.php b/tests/units/Job/ProjectMetricJobTest.php
new file mode 100644
index 00000000..e5b0474d
--- /dev/null
+++ b/tests/units/Job/ProjectMetricJobTest.php
@@ -0,0 +1,47 @@
+<?php
+
+use Kanboard\Job\ProjectMetricJob;
+
+require_once __DIR__.'/../Base.php';
+
+class ProjectMetricJobTest extends Base
+{
+ public function testJobParams()
+ {
+ $projectMetricJob = new ProjectMetricJob($this->container);
+ $projectMetricJob->withParams(123);
+
+ $this->assertSame(
+ array(123),
+ $projectMetricJob->getJobParams()
+ );
+ }
+
+ public function testJob()
+ {
+ $this->container['projectDailyColumnStatsModel'] = $this
+ ->getMockBuilder('\Kanboard\Model\ProjectDailyColumnStatsModel')
+ ->setConstructorArgs(array($this->container))
+ ->setMethods(array('updateTotals'))
+ ->getMock();
+
+ $this->container['projectDailyStatsModel'] = $this
+ ->getMockBuilder('\Kanboard\Model\ProjectDailyStatsModel')
+ ->setConstructorArgs(array($this->container))
+ ->setMethods(array('updateTotals'))
+ ->getMock();
+
+ $this->container['projectDailyColumnStatsModel']
+ ->expects($this->once())
+ ->method('updateTotals')
+ ->with(42, date('Y-m-d'));
+
+ $this->container['projectDailyStatsModel']
+ ->expects($this->once())
+ ->method('updateTotals')
+ ->with(42, date('Y-m-d'));
+
+ $job = new ProjectMetricJob($this->container);
+ $job->execute(42);
+ }
+}