|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the GitElephant package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Matteo Giachino <[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
|
|
|
* Just for fun... |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace GitElephant\Command; |
|
15
|
|
|
|
|
16
|
|
|
use GitElephant\TestCase; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Class RevParseCommandTest |
|
20
|
|
|
* |
|
21
|
|
|
* @author Matteo Giachino <[email protected]> |
|
22
|
|
|
*/ |
|
23
|
|
|
class RevParseCommandTest extends TestCase |
|
24
|
|
|
{ |
|
25
|
|
|
public function testRevParse(): void |
|
26
|
|
|
{ |
|
27
|
|
|
$c = RevParseCommand::getInstance(); |
|
28
|
|
|
$this->assertEquals("rev-parse 'master'", $c->revParse('master')); |
|
29
|
|
|
$this->assertEquals("rev-parse '--all' 'master'", $c->revParse('master', [RevParseCommand::OPTION_ALL])); |
|
30
|
|
|
$this->assertEquals("rev-parse '--all' '--abbrev-ref' 'master'", $c->revParse('master', [ |
|
31
|
|
|
RevParseCommand::OPTION_ALL, |
|
32
|
|
|
RevParseCommand::OPTION_ABBREV_REF |
|
33
|
|
|
])); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function testRevParseIsBare(): void |
|
37
|
|
|
{ |
|
38
|
|
|
$this->initRepository(null, 0); |
|
39
|
|
|
$repo = $this->getRepository(0); |
|
40
|
|
|
$repo->init(); |
|
41
|
|
|
|
|
42
|
|
|
$options = [RevParseCommand::OPTION_IS_BARE_REPOSIORY]; |
|
43
|
|
|
$c = RevParseCommand::getInstance()->revParse(null, $options); |
|
44
|
|
|
|
|
45
|
|
|
$caller = $repo->getCaller(); |
|
46
|
|
|
$caller->execute($c); |
|
47
|
|
|
$this->assertEquals(['false'], $caller->getOutputLines(true)); |
|
48
|
|
|
|
|
49
|
|
|
$this->initRepository(null, 1); |
|
50
|
|
|
$repo = $this->getRepository(1); |
|
51
|
|
|
$repo->init(true); |
|
52
|
|
|
|
|
53
|
|
|
$caller = $repo->getCaller(); |
|
54
|
|
|
$caller->execute($c); |
|
55
|
|
|
$this->assertEquals(['true'], $caller->getOutputLines(true)); |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|