|
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
|
|
|
public function testSimple() |
|
13
|
|
|
{ |
|
14
|
|
|
$schedule = new Schedule(['value' => '@daily']); |
|
15
|
|
|
|
|
16
|
|
|
$this->assertEquals('0 0 * * *', $schedule->runEvery); |
|
17
|
|
|
$this->assertTrue($schedule->active); |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
public function testInterval() |
|
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
|
|
|
|