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
|
|
|
|
13
|
|
|
namespace Siad007\VersionControl\HG\Tests\Command; |
14
|
|
|
|
15
|
|
|
use Siad007\VersionControl\HG\Factory; |
16
|
|
|
|
17
|
|
|
class CopyCommandTest extends \PHPUnit_Framework_TestCase |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @test |
21
|
|
|
*/ |
22
|
|
|
public function renameCommand() |
23
|
|
|
{ |
24
|
|
|
$copyCmd = Factory::createCopy(); |
25
|
|
|
$copyCmd->addSource('C:\\xampp\\source1\\'); |
26
|
|
|
$copyCmd->addSource('C:\\xampp\\source2\\'); |
27
|
|
|
$copyCmd->setDestination('C:\\xampp\\dest\\'); |
28
|
|
|
$copyCmd->setAfter(true); |
29
|
|
|
$copyCmd->addInclude('includePattern'); |
30
|
|
|
$copyCmd->addExclude('excludePattern'); |
31
|
|
|
$copyCmd->setForce(true); |
32
|
|
|
$copyCmd->setDryRun(true); |
33
|
|
|
|
34
|
|
|
$source = '\'C:\xampp\source1\\\' \'C:\xampp\source2\\\''; |
35
|
|
|
$dest = '\'C:\xampp\dest\\\''; |
36
|
|
|
$expected = 'hg copy --after --force --include includePattern --exclude excludePattern --dry-run '; |
37
|
|
|
|
38
|
|
|
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { |
39
|
|
|
$source = str_replace("'", '"', $source); |
40
|
|
|
$dest = str_replace("'", '"', $dest); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
$this->assertSame($source, implode(' ', $copyCmd->getSource())); |
44
|
|
|
$this->assertSame($dest, $copyCmd->getDestination()); |
45
|
|
|
$this->assertSame($expected . $source . ' ' . $dest, $copyCmd->asString()); |
46
|
|
|
} |
47
|
|
|
} |
48
|
|
|
|