|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* User: matteo |
|
5
|
|
|
* Date: 28/05/13 |
|
6
|
|
|
* Time: 18.36 |
|
7
|
|
|
* Just for fun... |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace GitElephant\Command; |
|
11
|
|
|
|
|
12
|
|
|
use GitElephant\TestCase; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Class MergeCommandTest |
|
16
|
|
|
* |
|
17
|
|
|
* @package GitElephant\Command |
|
18
|
|
|
*/ |
|
19
|
|
|
class MergeCommandTest extends TestCase |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* setUp |
|
23
|
|
|
*/ |
|
24
|
|
|
public function setUp(): void |
|
25
|
|
|
{ |
|
26
|
|
|
$this->initRepository(); |
|
27
|
|
|
$this->getRepository()->init(); |
|
28
|
|
|
$this->addFile('test'); |
|
29
|
|
|
$this->getRepository()->commit('test', true); |
|
30
|
|
|
$this->getRepository()->createBranch('test', 'master'); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* testMerge |
|
35
|
|
|
*/ |
|
36
|
|
|
public function testMerge(): void |
|
37
|
|
|
{ |
|
38
|
|
|
$mc = MergeCommand::getInstance(); |
|
39
|
|
|
$branch = $this->getRepository()->getBranch('test'); |
|
40
|
|
|
$this->assertEquals("merge 'refs/heads/test'", $mc->merge($branch)); |
|
41
|
|
|
$this->assertEquals("merge '-m' 'test msg' 'refs/heads/test'", $mc->merge($branch, "test msg")); |
|
42
|
|
|
$this->assertEquals( |
|
43
|
|
|
"merge '--ff-only' '-m' 'test msg' 'refs/heads/test'", |
|
44
|
|
|
$mc->merge($branch, "test msg", ['--ff-only']) |
|
45
|
|
|
); |
|
46
|
|
|
$this->assertEquals( |
|
47
|
|
|
"merge '--no-ff' '-m' 'test msg' 'refs/heads/test'", |
|
48
|
|
|
$mc->merge($branch, "test msg", ['--no-ff']) |
|
49
|
|
|
); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* MergeCommand should throw an exception when both --ff-only and --no-ff flags were set. |
|
54
|
|
|
*/ |
|
55
|
|
|
public function testExceptionWhenCallingMergeWithConflictingFfArguments(): void |
|
56
|
|
|
{ |
|
57
|
|
|
$branch = $this->getRepository()->getBranch('test'); |
|
58
|
|
|
$this->expectException(\Symfony\Component\Process\Exception\InvalidArgumentException::class); |
|
59
|
|
|
MergeCommand::getInstance()->merge($branch, "test msg", ['--ff-only', '--no-ff']); |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|