Completed
Push — master ( 55a9c0...ed128c )
by Emil
14:56
created

ScheduleTest::testSimple()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 7
Ratio 100 %

Importance

Changes 0
Metric Value
dl 7
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace Glooby\TaskBundle\Tests\Annotation\Schedule;
4
5
use Glooby\TaskBundle\Annotation\Schedule;
6
7
/**
8
 * @author Emil Kilhage
9
 */
10
class ScheduleTest extends \PHPUnit_Framework_TestCase
11
{
12 View Code Duplication
    public function testSimple()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
13
    {
14
        $schedule = new Schedule(['value' => '@daily']);
15
16
        $this->assertEquals('0 0 * * *', $schedule->runEvery);
17
        $this->assertTrue($schedule->active);
18
    }
19
20 View Code Duplication
    public function testInterval()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
21
    {
22
        $schedule = new Schedule(['runEvery' => '@daily']);
23
24
        $this->assertEquals('0 0 * * *', $schedule->runEvery);
25
        $this->assertTrue($schedule->active);
26
    }
27
28
    public function testIntervalActiveParams()
29
    {
30
        $schedule = new Schedule([
31
            'runEvery' => '@daily',
32
            'active' => false,
33
            'params' => [1],
34
        ]);
35
36
        $this->assertEquals('0 0 * * *', $schedule->runEvery);
37
        $this->assertEquals([1], $schedule->params);
38
        $this->assertFalse($schedule->active);
39
    }
40
41
    public function testParamsNonArray()
42
    {
43
        $this->setExpectedException('\InvalidArgumentException');
44
45
        new Schedule([
46
            'interval' => '@daily',
47
            'active' => false,
48
            'params' => 'foo',
49
        ]);
50
    }
51
52
    public function testInvalidProperty()
53
    {
54
        $this->setExpectedException('\InvalidArgumentException');
55
56
        new Schedule(['fooo' => '@daily']);
57
    }
58
59
    public function testInvalidInterval()
60
    {
61
        $this->setExpectedException('\InvalidArgumentException');
62
63
        new Schedule(['runEvery' => 'fdsfds fds']);
64
    }
65
66
    public function testMissingInvalid()
67
    {
68
        $this->setExpectedException('\InvalidArgumentException');
69
70
        new Schedule([]);
71
    }
72
73
    public function testInvalidTimeout()
74
    {
75
        $this->setExpectedException('\InvalidArgumentException');
76
77
        new Schedule(['interval' => '@daily', 'timeout' => 'x']);
78
    }
79
}
80