|
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
|
|
|
|
|
33
|
|
|
class PullCommandTest extends TestCase |
|
34
|
|
|
{ |
|
35
|
|
|
/** |
|
36
|
|
|
* set up |
|
37
|
|
|
*/ |
|
38
|
|
|
public function setUp(): void |
|
39
|
|
|
{ |
|
40
|
|
|
$this->initRepository(); |
|
41
|
|
|
$this->getRepository()->init(); |
|
42
|
|
|
$this->addFile('test'); |
|
43
|
|
|
$this->getRepository()->commit('test', true); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* clone url |
|
48
|
|
|
*/ |
|
49
|
|
|
public function testPull(): void |
|
50
|
|
|
{ |
|
51
|
|
|
$pc = PullCommand::getInstance(); |
|
52
|
|
|
$this->assertEquals("pull", $pc->pull()); |
|
53
|
|
|
$this->assertEquals("pull 'github'", $pc->pull('github')); |
|
54
|
|
|
$this->assertEquals("pull 'github' 'develop'", $pc->pull('github', 'develop')); |
|
55
|
|
|
$this->getRepository()->addRemote('test-remote', '[email protected]:matteosister/GitElephant.git'); |
|
56
|
|
|
$remote = m::mock('GitElephant\Objects\Remote') |
|
57
|
|
|
->shouldReceive('getName')->andReturn('test-remote')->getMock(); |
|
58
|
|
|
$this->assertEquals("pull 'test-remote' 'develop'", $pc->pull($remote, 'develop')); |
|
59
|
|
|
$branch = Branch::create($this->getRepository(), 'test-branch'); |
|
60
|
|
|
$this->assertEquals("pull 'test-remote' 'test-branch'", $pc->pull($remote, $branch)); |
|
61
|
|
|
$this->assertEquals("pull '--rebase'", $pc->pull(null, null, true)); |
|
62
|
|
|
$this->assertEquals("pull '--rebase' 'test-remote' 'test-branch'", $pc->pull($remote, $branch, true)); |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|