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