CronJobTest::testNextRun()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace Alpixel\Bundle\CronBundle\Tests\Entity;
4
5
class CronJobTest extends \PHPUnit_Framework_TestCase
6
{
7
    public function testCommand()
8
    {
9
        $cronjob = $this->getCronJob();
10
        $this->assertNull($cronjob->getCommand());
11
12
        $cronjob->setCommand('execute.sh');
13
        $this->assertEquals('execute.sh', $cronjob->getCommand());
14
    }
15
16
    public function testDescription()
17
    {
18
        $cronjob = $this->getCronJob();
19
        $this->assertNull($cronjob->getDescription());
20
21
        $cronjob->setDescription('Such a nice description');
22
        $this->assertEquals('Such a nice description', $cronjob->getDescription());
23
    }
24
25
    public function testInterval()
26
    {
27
        $cronjob = $this->getCronJob();
28
        $this->assertNull($cronjob->getInterval());
29
30
        $cronjob->setInterval('PT1S');
31
        $this->assertEquals('PT1S', $cronjob->getInterval());
32
    }
33
34
    public function testNextRun()
35
    {
36
        $cronjob = $this->getCronJob();
37
        $this->assertNull($cronjob->getNextRun());
38
39
        $cronjob->setNextRun(new \DateTime('+4 hours'));
40
        $this->assertEquals(new \DateTime('+4 hours'), $cronjob->getNextRun());
41
    }
42
43
    public function testEnabled()
44
    {
45
        $cronjob = $this->getCronJob();
46
        $this->assertNull($cronjob->getEnabled());
47
48
        $cronjob->setEnabled(true);
49
        $this->assertEquals(true, $cronjob->getEnabled());
50
    }
51
52
    public function testResults()
53
    {
54
        $cronjob = $this->getCronJob();
55
        $this->assertCount(0, $cronjob->getResults());
56
    }
57
58
    public function testMostRecentRun()
59
    {
60
        $cronjob = $this->getCronJob();
61
        $this->assertNull($cronjob->getMostRecentRun());
62
63
        $result = $this->getMockForAbstractClass('Alpixel\Bundle\CronBundle\Entity\CronJobResult');
64
65
        $cronjob->setMostRecentRun($result);
66
        $this->assertEquals($result, $cronjob->getMostRecentRun());
67
    }
68
69
    public function getCronJob()
70
    {
71
        return $this->getMockForAbstractClass('Alpixel\Bundle\CronBundle\Entity\CronJob');
72
    }
73
}
74