summaryrefslogtreecommitdiff
path: root/tests/units/Job/ProjectMetricJobTest.php
blob: e5b0474def31098bc53c13651c2f0400bfe6408b (plain)
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
<?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);
    }
}