|
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
|
|
|
|