Completed
Push — develop ( b29d0d...9c2be0 )
by
unknown
16s queued 11s
created

MergeCommandTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 37
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 8 1
A testMerge() 0 9 1
A testExceptionWhenCallingMergeWithConflictingFfArguments() 0 6 1
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