HookTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 24
dl 0
loc 48
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testSetEnabled() 0 8 1
A testEmptyActions() 0 7 1
A testDisabledByDefault() 0 7 1
A testAddMultiAction() 0 8 1
A testAddAction() 0 8 1
1
<?php
2
3
/**
4
 * This file is part of CaptainHook
5
 *
6
 * (c) Sebastian Feldmann <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace CaptainHook\App\Config;
13
14
use PHPUnit\Framework\TestCase;
15
16
class HookTest extends TestCase
17
{
18
    public function testDisabledByDefault(): void
19
    {
20
        $hook   = new Hook('pre-commit');
21
        $config = $hook->getJsonData();
22
23
        $this->assertFalse($hook->isEnabled());
24
        $this->assertFalse($config['enabled']);
25
    }
26
27
    public function testSetEnabled(): void
28
    {
29
        $hook   = new Hook('pre-commit');
30
        $hook->setEnabled(true);
31
        $config = $hook->getJsonData();
32
33
        $this->assertTrue($hook->isEnabled());
34
        $this->assertTrue($config['enabled']);
35
    }
36
37
    public function testEmptyActions(): void
38
    {
39
        $hook   = new Hook('pre-commit');
40
        $config = $hook->getJsonData();
41
42
        $this->assertCount(0, $hook->getActions());
43
        $this->assertCount(0, $config['actions']);
44
    }
45
46
    public function testAddAction(): void
47
    {
48
        $hook   = new Hook('pre-commit');
49
        $hook->addAction(new Action('\\Foo\\Bar'));
50
        $config = $hook->getJsonData();
51
52
        $this->assertCount(1, $hook->getActions());
53
        $this->assertCount(1, $config['actions']);
54
    }
55
56
    public function testAddMultiAction(): void
57
    {
58
        $hook   = new Hook('pre-commit');
59
        $hook->addAction(new Action('\\Foo\\Bar'), new Action('\\Foo\\Bar'));
60
        $config = $hook->getJsonData();
61
62
        $this->assertCount(2, $hook->getActions());
63
        $this->assertCount(2, $config['actions']);
64
    }
65
}
66