CronJobTest   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 69
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A testDescription() 0 8 1
A testInterval() 0 8 1
A testNextRun() 0 8 1
A testEnabled() 0 8 1
A testResults() 0 5 1
A testMostRecentRun() 0 10 1
A getCronJob() 0 4 1
A testCommand() 0 8 1
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