|
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
|
|
|
* BranchTest |
|
20
|
|
|
* |
|
21
|
|
|
* Branch test |
|
22
|
|
|
* |
|
23
|
|
|
* @author Matteo Giachino <[email protected]> |
|
24
|
|
|
*/ |
|
25
|
|
|
class BranchCommandTest extends TestCase |
|
26
|
|
|
{ |
|
27
|
|
|
/** |
|
28
|
|
|
* setUp, called on every method |
|
29
|
|
|
*/ |
|
30
|
|
|
public function setUp(): void |
|
31
|
|
|
{ |
|
32
|
|
|
$this->initRepository(); |
|
33
|
|
|
$this->getRepository()->init(); |
|
34
|
|
|
$this->addFile('test'); |
|
35
|
|
|
$this->getRepository()->commit('first commit', true); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* create test |
|
40
|
|
|
* |
|
41
|
|
|
* @covers GitElephant\Command\BranchCommand::create |
|
42
|
|
|
*/ |
|
43
|
|
|
public function testCreate(): void |
|
44
|
|
|
{ |
|
45
|
|
|
$branch = new BranchCommand(); |
|
46
|
|
|
$this->assertEquals("branch 'test'", $branch->create('test'), 'create branch command'); |
|
47
|
|
|
$this->assertEquals(1, count($this->getRepository()->getBranches()), 'one branch in initiated git repo'); |
|
48
|
|
|
$this->getCaller()->execute($branch->create('test')); |
|
49
|
|
|
$this->assertEquals(2, count($this->getRepository()->getBranches()), 'two branches after add branch command'); |
|
50
|
|
|
$this->getCaller()->execute($branch->create('test2')); |
|
51
|
|
|
$this->assertEquals(3, count($this->getRepository()->getBranches()), 'three branches after add branch command'); |
|
52
|
|
|
$this->assertEquals("branch 'test' 'master'", $branch->create('test', 'master')); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* listBranches test |
|
57
|
|
|
* |
|
58
|
|
|
* @covers GitElephant\Command\BranchCommand::listBranches |
|
59
|
|
|
*/ |
|
60
|
|
|
public function testListBranches(): void |
|
61
|
|
|
{ |
|
62
|
|
|
$branch = new BranchCommand(); |
|
63
|
|
|
$this->assertEquals($branch->listBranches(), "branch '-v' '--no-color' '--no-abbrev'"); |
|
64
|
|
|
$this->assertEquals($branch->listBranches(true), "branch '-v' '--no-color' '--no-abbrev' '-a'"); |
|
65
|
|
|
$this->assertEquals($branch->listBranches(false, true), "branch '--no-color' '--no-abbrev'"); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* lists test |
|
70
|
|
|
* |
|
71
|
|
|
* @covers GitElephant\Command\BranchCommand::lists |
|
72
|
|
|
*/ |
|
73
|
|
|
public function testLists(): void |
|
74
|
|
|
{ |
|
75
|
|
|
$branch = new BranchCommand(); |
|
76
|
|
|
$this->assertEquals($branch->lists(), "branch '-v' '--no-color' '--no-abbrev'"); |
|
|
|
|
|
|
77
|
|
|
$this->assertEquals($branch->lists(true), "branch '-v' '--no-color' '--no-abbrev' '-a'"); |
|
|
|
|
|
|
78
|
|
|
$this->assertEquals($branch->lists(false, true), "branch '--no-color' '--no-abbrev'"); |
|
|
|
|
|
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* testSingleInfo |
|
83
|
|
|
*/ |
|
84
|
|
|
public function testSingleInfo(): void |
|
85
|
|
|
{ |
|
86
|
|
|
$bc = new BranchCommand(); |
|
87
|
|
|
$this->assertEquals( |
|
88
|
|
|
"branch '-v' '--list' '--no-color' '--no-abbrev' 'master'", |
|
89
|
|
|
$bc->singleInfo('master') |
|
90
|
|
|
); |
|
91
|
|
|
$this->assertEquals( |
|
92
|
|
|
"branch '-v' '--list' '--no-color' '--no-abbrev' '-a' 'master'", |
|
93
|
|
|
$bc->singleInfo('master', true) |
|
94
|
|
|
); |
|
95
|
|
|
$this->assertEquals( |
|
96
|
|
|
"branch '-v' '--list' '--no-color' '--no-abbrev' '-a' '-vv' 'master'", |
|
97
|
|
|
$bc->singleInfo('master', true, false, true) |
|
98
|
|
|
); |
|
99
|
|
|
$this->assertEquals( |
|
100
|
|
|
"branch '--list' '--no-color' '--no-abbrev' '-a' '-vv' 'master'", |
|
101
|
|
|
$bc->singleInfo('master', true, true, true) |
|
102
|
|
|
); |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* delete test |
|
107
|
|
|
* |
|
108
|
|
|
* @covers GitElephant\Command\BranchCommand::delete |
|
109
|
|
|
*/ |
|
110
|
|
|
public function testDelete(): void |
|
111
|
|
|
{ |
|
112
|
|
|
$branch = new BranchCommand(); |
|
113
|
|
|
$this->assertEquals( |
|
114
|
|
|
"branch '-d' 'test-branch'", |
|
115
|
|
|
$branch->delete('test-branch'), |
|
116
|
|
|
'list branch command without force' |
|
117
|
|
|
); |
|
118
|
|
|
$this->assertEquals( |
|
119
|
|
|
"branch '-D' 'test-branch'", |
|
120
|
|
|
$branch->delete('test-branch', true), |
|
121
|
|
|
'list branch command with force' |
|
122
|
|
|
); |
|
123
|
|
|
} |
|
124
|
|
|
} |
|
125
|
|
|
|
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.