|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* VersionControl_HG |
|
4
|
|
|
* Simple OO implementation for Mercurial. |
|
5
|
|
|
* |
|
6
|
|
|
* PHP Version 5.4 |
|
7
|
|
|
* |
|
8
|
|
|
* @copyright 2014 Siad Ardroumli |
|
9
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT |
|
10
|
|
|
* @link http://siad007.github.io/versioncontrol_hg |
|
11
|
|
|
*/ |
|
12
|
|
|
namespace Siad007\VersionControl\HG\Tests\Command; |
|
13
|
|
|
|
|
14
|
|
|
use Siad007\VersionControl\HG\Factory; |
|
15
|
|
|
use Siad007\VersionControl\HG\Tests\Helpers\TestCase; |
|
16
|
|
|
|
|
17
|
|
|
class CloneCommandTest extends TestCase |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @test |
|
21
|
|
|
*/ |
|
22
|
|
|
public function cloneCommand() |
|
23
|
|
|
{ |
|
24
|
|
|
$cloneCmd = Factory::createClone(); |
|
25
|
|
|
$cloneCmd->setSource('C:\\xampp\\source\\'); |
|
26
|
|
|
$cloneCmd->setDestination('C:\\xampp\\dest\\'); |
|
27
|
|
|
$cloneCmd->setUncompressed(true); |
|
28
|
|
|
$cloneCmd->setInsecure(true); |
|
29
|
|
|
|
|
30
|
|
|
$destination = '\'C:\xampp\dest\\\''; |
|
31
|
|
|
$source = '\'C:\xampp\source\\\''; |
|
32
|
|
|
$expected = "hg clone --uncompressed --insecure "; |
|
33
|
|
|
|
|
34
|
|
|
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { |
|
35
|
|
|
$destination = str_replace("'", '"', $destination); |
|
36
|
|
|
$source = str_replace("'", '"', $source); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
$this->assertSame($destination, $cloneCmd->getDestination()); |
|
40
|
|
|
$this->assertSame($source, $cloneCmd->getSource()); |
|
41
|
|
|
$this->assertSame($expected . $source . ' ' . $destination, $cloneCmd->asString()); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @test |
|
46
|
|
|
*/ |
|
47
|
|
|
public function cloneCommandWithoutDestination() |
|
48
|
|
|
{ |
|
49
|
|
|
$cloneCmd = Factory::createClone(); |
|
50
|
|
|
$cloneCmd->setSource('C:\\xampp\\source'); |
|
51
|
|
|
$cloneCmd->setUncompressed(true); |
|
52
|
|
|
$cloneCmd->setInsecure(true); |
|
53
|
|
|
|
|
54
|
|
|
$expected = 'hg clone --uncompressed --insecure \'C:\xampp\source\''; |
|
55
|
|
|
|
|
56
|
|
|
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { |
|
57
|
|
|
$expected = str_replace("'", '"', $expected); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
$this->assertSame($expected, $cloneCmd->asString()); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @test |
|
65
|
|
|
*/ |
|
66
|
|
|
public function cloneCommandWithoutSource() |
|
67
|
|
|
{ |
|
68
|
|
|
/* @var $cloneCmd \Siad007\VersionControl\HG\Command\CloneCommand */ |
|
69
|
|
|
$cloneCmd = Factory::getInstance('clone'); |
|
70
|
|
|
$cloneCmd->setUncompressed(true); |
|
71
|
|
|
$cloneCmd->setInsecure(true); |
|
72
|
|
|
$cloneCmd->asString(); |
|
73
|
|
|
|
|
74
|
|
|
$this->assertError("No source directory given.", E_USER_ERROR); |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|