1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of CaptainHook. |
4
|
|
|
* |
5
|
|
|
* (c) Sebastian Feldmann <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
namespace CaptainHook\App\Config; |
11
|
|
|
|
12
|
|
|
use PHPUnit\Framework\TestCase; |
13
|
|
|
|
14
|
|
|
class ActionTest extends TestCase |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* Tests Action::getAction |
18
|
|
|
*/ |
19
|
|
|
public function testGetAction(): void |
20
|
|
|
{ |
21
|
|
|
$action = new Action('\\Foo\\Bar'); |
22
|
|
|
|
23
|
|
|
$this->assertEquals('\\Foo\\Bar', $action->getAction()); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Tests Action::getOptions |
28
|
|
|
*/ |
29
|
|
|
public function testGetOptions(): void |
30
|
|
|
{ |
31
|
|
|
$action = new Action('\\Foo\\Bar'); |
32
|
|
|
|
33
|
|
|
$this->assertEquals([], $action->getOptions()->getAll()); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Tests Action::getJsonData |
38
|
|
|
*/ |
39
|
|
|
public function testEmptyOptions(): void |
40
|
|
|
{ |
41
|
|
|
$action = new Action('\\Foo\\Bar'); |
42
|
|
|
$config = $action->getJsonData(); |
43
|
|
|
|
44
|
|
|
$this->assertCount(0, $config['options']); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Tests Action::getJsonData |
49
|
|
|
*/ |
50
|
|
|
public function testConditions(): void |
51
|
|
|
{ |
52
|
|
|
$conditions = [ |
53
|
|
|
['exec' => '\\Foo\\Bar', 'args' => []] |
54
|
|
|
]; |
55
|
|
|
|
56
|
|
|
$action = new Action('\\Foo\\Bar', [], $conditions); |
57
|
|
|
$config = $action->getJsonData(); |
58
|
|
|
|
59
|
|
|
$this->assertCount(1, $config['conditions']); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Tests Action::getConditions |
64
|
|
|
*/ |
65
|
|
|
public function testGetConditions(): void |
66
|
|
|
{ |
67
|
|
|
$conditions = [ |
68
|
|
|
['exec' => '\\Foo\\Bar', 'args' => []], |
69
|
|
|
['exec' => '\\Fiz\\Baz', 'args' => []] |
70
|
|
|
]; |
71
|
|
|
|
72
|
|
|
$action = new Action('\\Foo\\Bar', [], $conditions); |
73
|
|
|
|
74
|
|
|
$this->assertCount(2, $action->getConditions()); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|