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 RenameCommandTest extends \PHPUnit_Framework_TestCase |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @test |
21
|
|
|
*/ |
22
|
|
|
public function renameCommand() |
23
|
|
|
{ |
24
|
|
|
$renameCmd = Factory::createRename(); |
25
|
|
|
$renameCmd->addSource('C:\\xampp\\source1\\'); |
26
|
|
|
$renameCmd->addSource('C:\\xampp\\source2\\'); |
27
|
|
|
$renameCmd->setDestination('C:\\xampp\\dest\\'); |
28
|
|
|
$renameCmd->setAfter(true); |
29
|
|
|
$renameCmd->addInclude('includePattern'); |
30
|
|
|
$renameCmd->addExclude('excludePattern'); |
31
|
|
|
$renameCmd->setForce(true); |
32
|
|
|
|
33
|
|
|
$source = '\'C:\xampp\source1\\\' \'C:\xampp\source2\\\''; |
34
|
|
|
$dest = '\'C:\xampp\dest\\\''; |
35
|
|
|
$expected = 'hg rename --after --force --include includePattern --exclude excludePattern '; |
36
|
|
|
|
37
|
|
|
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { |
38
|
|
|
$source = str_replace("'", '"', $source); |
39
|
|
|
$dest = str_replace("'", '"', $dest); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
$this->assertSame($source, implode(' ', $renameCmd->getSource())); |
43
|
|
|
$this->assertSame($dest, $renameCmd->getDestination()); |
44
|
|
|
$this->assertSame($expected . $source . ' ' . $dest, $renameCmd->asString()); |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
|