Completed
Push — master ( 48965b...c1a738 )
by
unknown
111:36 queued 110:10
created

testExceptionWhenCallingMergeWithConflictingFfArguments()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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