Passed
Push — master ( 7bee4d...457c92 )
by Sebastian
01:54
created

ActionTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 18
dl 0
loc 61
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetConditions() 0 10 1
A testConditions() 0 10 1
A testGetAction() 0 5 1
A testGetOptions() 0 5 1
A testEmptyOptions() 0 6 1
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