Completed
Push — develop ( 5f7df1...9cb564 )
by Matteo
10s
created

RevParseCommandTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 3
Bugs 1 Features 0
Metric Value
wmc 2
c 3
b 1
f 0
lcom 1
cbo 4
dl 0
loc 35
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testRevParse() 0 10 1
A testRevParseIsBare() 0 21 1
1
<?php
2
/**
3
 * This file is part of the GitElephant package.
4
 *
5
 * (c) Matteo Giachino <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * Just for fun...
11
 */
12
13
namespace GitElephant\Command;
14
15
use \GitElephant\Objects\Branch;
16
use \GitElephant\Repository;
17
use \GitElephant\TestCase;
18
19
/**
20
 * Class RevParseCommandTest
21
 *
22
 * @author Matteo Giachino <[email protected]>
23
 */
24
class RevParseCommandTest extends TestCase
25
{
26
    public function testRevParse()
27
    {
28
        $c = RevParseCommand::getInstance();
29
        $this->assertEquals("rev-parse 'master'", $c->revParse('master'));
30
        $this->assertEquals("rev-parse '--all' 'master'", $c->revParse('master', array(RevParseCommand::OPTION_ALL)));
31
        $this->assertEquals("rev-parse '--all' '--abbrev-ref' 'master'", $c->revParse('master', array(
32
            RevParseCommand::OPTION_ALL,
33
            RevParseCommand::OPTION_ABBREV_REF
34
        )));
35
    }
36
37
    public function testRevParseIsBare()
38
    {
39
        $this->initRepository(null, 0);
40
        $repo = $this->getRepository(0);
41
        $repo->init();
42
43
        $options = array(RevParseCommand::OPTION_IS_BARE_REPOSIORY);
44
        $c = RevParseCommand::getInstance()->revParse(null, $options);
45
46
        $caller = $repo->getCaller();
47
        $caller->execute($c);
48
        $this->assertEquals(array('false'), $caller->getOutputLines(true));
49
50
        $this->initRepository(null, 1);
51
        $repo = $this->getRepository(1);
52
        $repo->init(true);
53
54
        $caller = $repo->getCaller();
55
        $caller->execute($c);
56
        $this->assertEquals(array('true'), $caller->getOutputLines(true));
57
    }
58
}
59