FetchCommandTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * GitElephant - An abstraction layer for git written in PHP
5
 * Copyright (C) 2013  Matteo Giachino
6
 *
7
 * This program is free software: you can redistribute it and/or modify
8
 * it under the terms of the GNU General Public License as published by
9
 * the Free Software Foundation, either version 3 of the License, or
10
 * (at your option) any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 * GNU General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU General Public License
18
 * along with this program.  If not, see [http://www.gnu.org/licenses/].
19
 */
20
21
namespace GitElephant\Command;
22
23
use GitElephant\Objects\Branch;
24
use GitElephant\TestCase;
25
use Mockery as m;
26
27
/**
28
 * CloneCommandTest
29
 *
30
 * @author Matteo Giachino <[email protected]>
31
 */
32
class FetchCommandTest extends TestCase
33
{
34
    /**
35
     * set up
36
     */
37
    public function setUp(): void
38
    {
39
        $this->initRepository();
40
        $this->getRepository()->init();
41
        $this->addFile('test');
42
        $this->getRepository()->commit('test', true);
43
    }
44
45
    /**
46
     * fetch test
47
     */
48
    public function testFetch(): void
49
    {
50
        $fc = FetchCommand::getInstance();
51
        $this->assertEquals("fetch", $fc->fetch());
52
        $this->assertEquals("fetch 'github'", $fc->fetch('github'));
53
        $this->assertEquals("fetch 'github' 'develop'", $fc->fetch('github', 'develop'));
54
        $this->getRepository()->addRemote('test-remote', '[email protected]:matteosister/GitElephant.git');
55
        $remote = m::mock('GitElephant\Objects\Remote')
56
            ->shouldReceive('getName')->andReturn('test-remote')->getMock();
57
        $this->assertEquals("fetch 'test-remote' 'develop'", $fc->fetch($remote, 'develop'));
58
        $branch = Branch::create($this->getRepository(), 'test-branch');
59
        $this->assertEquals("fetch 'test-remote' 'test-branch'", $fc->fetch($remote, $branch));
60
        $this->assertEquals(
61
            "fetch '--tags' 'test-remote' 'test-branch'",
62
            $fc->fetch($remote, $branch, ['--tags'])
63
        );
64
    }
65
}
66