Passed
Push — master ( 813fe9...62056b )
by Sebastian
06:01
created

UtilTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 43
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testIsValid() 0 7 1
A testGetValidHooks() 0 6 1
A testGetHooks() 0 6 1
A testGetActionType() 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\Hook;
11
12
class UtilTest extends \PHPUnit_Framework_TestCase
13
{
14
    /**
15
     * Tests Util::isValid
16
     */
17
    public function testIsValid()
18
    {
19
        $this->assertTrue(Util::isValid('pre-commit'));
20
        $this->assertTrue(Util::isValid('pre-push'));
21
        $this->assertTrue(Util::isValid('commit-msg'));
22
        $this->assertFalse(Util::isValid('foo'));
23
    }
24
25
    /**
26
     * Tests Util::getValidHooks
27
     */
28
    public function testGetValidHooks()
29
    {
30
        $this->assertTrue(array_key_exists('pre-commit', Util::getValidHooks()));
31
        $this->assertTrue(array_key_exists('pre-push', Util::getValidHooks()));
32
        $this->assertTrue(array_key_exists('commit-msg', Util::getValidHooks()));
33
    }
34
35
    /**
36
     * Tests Util::getHooks
37
     */
38
    public function testGetHooks()
39
    {
40
        $this->assertTrue(in_array('pre-commit', Util::getHooks()));
41
        $this->assertTrue(in_array('pre-push', Util::getHooks()));
42
        $this->assertTrue(in_array('commit-msg', Util::getHooks()));
43
    }
44
45
    /**
46
     * Tests Util::getActionType
47
     */
48
    public function testGetActionType()
49
    {
50
        $this->assertEquals('php', Util::getActionType('\\Foo\\Bar'));
51
        $this->assertEquals('cli', Util::getActionType('echo foo'));
52
        $this->assertEquals('cli', Util::getActionType('/usr/local/bin/phpunit.phar'));
53
    }
54
}
55