Passed
Push — main ( bd00ab...4bee9b )
by Sebastian
04:41
created

UtilTest::testExtractBranchInfoDefaultRemote()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
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\Git\Rev;
13
14
use PHPUnit\Framework\TestCase;
15
16
/**
17
 *
18
 */
19
class UtilTest extends TestCase
20
{
21
    /**
22
     * Tests: Util::isZeroHash
23
     */
24
    public function testIsZeroHash()
25
    {
26
        $this->assertTrue(Util::isZeroHash('00000000000000000'));
27
        $this->assertTrue(Util::isZeroHash('0000000'));
28
        $this->assertFalse(Util::isZeroHash('ef65da'));
29
    }
30
31
    /**
32
     * Tests: Util::extractBranchInfo
33
     */
34
    public function testExtractBranchInfoDefaultRemote()
35
    {
36
        $info = Util::extractBranchInfo('foo-bar-baz');
37
        $this->assertEquals('origin', $info['remote']);
38
        $this->assertEquals('foo-bar-baz', $info['branch']);
39
    }
40
41
    /**
42
     * Tests: Util::extractBranchInfo
43
     */
44
    public function testExtractBranchInfoWithRef()
45
    {
46
        $info = Util::extractBranchInfo('refs/origin/foo');
47
        $this->assertEquals('origin', $info['remote']);
48
        $this->assertEquals('foo', $info['branch']);
49
    }
50
51
    /**
52
     * Tests: Util::extractBranchInfo
53
     */
54
    public function testExtractBranchInfoWithSlashInBranchName()
55
    {
56
        $info = Util::extractBranchInfo('refs/source/feature/foo');
57
        $this->assertEquals('source', $info['remote']);
58
        $this->assertEquals('feature/foo', $info['branch']);
59
    }
60
}
61