Completed
Pull Request — master (#166)
by
unknown
112:06 queued 110:39
created

MainCommandTest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 2
dl 0
loc 78
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testInit() 0 5 1
A testStatus() 0 4 1
A testAdd() 0 5 1
A testUnstage() 0 4 1
A testCommit() 0 17 1
A testCheckout() 0 4 1
1
<?php
2
3
/**
4
 * This file is part of the GitElephant package.
5
 *
6
 * (c) M
7
 * atteo Giachino <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 *
12
 * Just for fun...
13
 */
14
15
namespace GitElephant\Command;
16
17
use GitElephant\TestCase;
18
19
/**
20
 * MainTest
21
 *
22
 * MainCommand class tests
23
 *
24
 * @author Matteo Giachino <[email protected]>
25
 */
26
27
class MainCommandTest extends TestCase
28
{
29
    /**
30
     * @var \GitElephant\Command\MainCommand ;
31
     */
32
    private $mainCommand;
33
34
    /**
35
     * setup
36
     */
37
    public function setUp(): void
38
    {
39
        $this->mainCommand = new MainCommand();
40
    }
41
42
    /**
43
     * init test
44
     */
45
    public function testInit(): void
46
    {
47
        $this->assertEquals(MainCommand::GIT_INIT, $this->mainCommand->init());
48
        $this->assertEquals(MainCommand::GIT_INIT . " '--bare'", $this->mainCommand->init(true));
49
    }
50
51
    /**
52
     * status test
53
     */
54
    public function testStatus(): void
55
    {
56
        $this->assertEquals("'-c' 'color.status'='false' " . MainCommand::GIT_STATUS, $this->mainCommand->status());
57
    }
58
59
    /**
60
     * add test
61
     */
62
    public function testAdd(): void
63
    {
64
        $this->assertEquals(MainCommand::GIT_ADD . " '--all' '.'", $this->mainCommand->add());
65
        $this->assertEquals(MainCommand::GIT_ADD . " '--all' 'foo'", $this->mainCommand->add('foo'));
66
    }
67
68
    /**
69
     * unstage test
70
     */
71
    public function testUnstage(): void
72
    {
73
        $this->assertEquals(MainCommand::GIT_RESET . " 'HEAD' -- 'foo'", $this->mainCommand->unstage('foo'));
74
    }
75
76
    /**
77
     * commit test
78
     */
79
    public function testCommit(): void
80
    {
81
        $this->assertEquals(MainCommand::GIT_COMMIT . " '-m' 'foo'", $this->mainCommand->commit('foo'));
82
        $this->assertEquals(MainCommand::GIT_COMMIT . " '-a' '-m' 'foo'", $this->mainCommand->commit('foo', true));
83
        $this->assertEquals(
84
            MainCommand::GIT_COMMIT . " '--author' 'example <[email protected]>' '-m' 'foo'",
85
            $this->mainCommand->commit('foo', false, 'example <[email protected]>')
86
        );
87
        $this->assertEquals(
88
            MainCommand::GIT_COMMIT . " '-a' '--author' 'example <[email protected]>' '-m' 'foo'",
89
            $this->mainCommand->commit('foo', true, 'example <[email protected]>')
90
        );
91
        $this->assertEquals(
92
            MainCommand::GIT_COMMIT . " '--author' 'example <[email protected]>' '--allow-empty' '-m' 'foo'",
93
            $this->mainCommand->commit('foo', false, 'example <[email protected]>', true)
94
        );
95
    }
96
97
    /**
98
     * checkout test
99
     */
100
    public function testCheckout(): void
101
    {
102
        $this->assertEquals(MainCommand::GIT_CHECKOUT . " '-q' 'master'", $this->mainCommand->checkout('master'));
103
    }
104
}
105