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

MainCommandTest::testInit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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
use \GitElephant\Command\MainCommand;
19
20
/**
21
 * MainTest
22
 *
23
 * MainCommand class tests
24
 *
25
 * @author Matteo Giachino <[email protected]>
26
 */
27
28
class MainCommandTest extends TestCase
29
{
30
    /**
31
     * @var \GitElephant\Command\MainCommand ;
32
     */
33
    private $mainCommand;
34
35
    /**
36
     * setup
37
     */
38
    public function setUp(): void
39
    {
40
        $this->mainCommand = new MainCommand();
41
    }
42
43
    /**
44
     * init test
45
     */
46
    public function testInit(): void
47
    {
48
        $this->assertEquals(MainCommand::GIT_INIT, $this->mainCommand->init());
49
        $this->assertEquals(MainCommand::GIT_INIT . " '--bare'", $this->mainCommand->init(true));
50
    }
51
52
    /**
53
     * status test
54
     */
55
    public function testStatus(): void
56
    {
57
        $this->assertEquals("'-c' 'color.status'='false' " . MainCommand::GIT_STATUS, $this->mainCommand->status());
58
    }
59
60
    /**
61
     * add test
62
     */
63
    public function testAdd(): void
64
    {
65
        $this->assertEquals(MainCommand::GIT_ADD . " '--all' '.'", $this->mainCommand->add());
66
        $this->assertEquals(MainCommand::GIT_ADD . " '--all' 'foo'", $this->mainCommand->add('foo'));
67
    }
68
69
    /**
70
     * unstage test
71
     */
72
    public function testUnstage(): void
73
    {
74
        $this->assertEquals(MainCommand::GIT_RESET . " 'HEAD' -- 'foo'", $this->mainCommand->unstage('foo'));
75
    }
76
77
    /**
78
     * commit test
79
     */
80
    public function testCommit(): void
81
    {
82
        $this->assertEquals(MainCommand::GIT_COMMIT . " '-m' 'foo'", $this->mainCommand->commit('foo'));
83
        $this->assertEquals(MainCommand::GIT_COMMIT . " '-a' '-m' 'foo'", $this->mainCommand->commit('foo', true));
84
        $this->assertEquals(
85
            MainCommand::GIT_COMMIT . " '--author' 'example <[email protected]>' '-m' 'foo'",
86
            $this->mainCommand->commit('foo', false, 'example <[email protected]>')
87
        );
88
        $this->assertEquals(
89
            MainCommand::GIT_COMMIT . " '-a' '--author' 'example <[email protected]>' '-m' 'foo'",
90
            $this->mainCommand->commit('foo', true, 'example <[email protected]>')
91
        );
92
        $this->assertEquals(
93
            MainCommand::GIT_COMMIT . " '--author' 'example <[email protected]>' '--allow-empty' '-m' 'foo'",
94
            $this->mainCommand->commit('foo', false, 'example <[email protected]>', true)
95
        );
96
    }
97
98
    /**
99
     * checkout test
100
     */
101
    public function testCheckout(): void
102
    {
103
        $this->assertEquals(MainCommand::GIT_CHECKOUT . " '-q' 'master'", $this->mainCommand->checkout('master'));
104
    }
105
}
106