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 CommitCommandTest extends \PHPUnit_Framework_TestCase |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @test |
21
|
|
|
*/ |
22
|
|
|
public function commitCommand() |
23
|
|
|
{ |
24
|
|
|
$commitCmd = Factory::createCommit(); |
25
|
|
|
$commitCmd->addFile('C:\\xampp\\file1\\'); |
26
|
|
|
$commitCmd->addFile('C:\\xampp\\file2\\'); |
27
|
|
|
$commitCmd->setAddremove(true); |
28
|
|
|
$commitCmd->setCloseBranch(true); |
29
|
|
|
$commitCmd->setAmend(true); |
30
|
|
|
$commitCmd->setSecret(true); |
31
|
|
|
$commitCmd->setEdit(true); |
32
|
|
|
$commitCmd->addInclude('includePattern'); |
33
|
|
|
$commitCmd->addExclude('excludePattern'); |
34
|
|
|
$commitCmd->setMessage('text'); |
35
|
|
|
$commitCmd->setLogfile('logfile'); |
36
|
|
|
$commitCmd->setDate('date'); |
37
|
|
|
$commitCmd->setUser('user'); |
38
|
|
|
$commitCmd->setSubrepos(true); |
39
|
|
|
|
40
|
|
|
$file = '\'C:\xampp\file1\\\' \'C:\xampp\file2\\\''; |
41
|
|
|
$expected = 'hg commit --addremove --close-branch --amend --secret --edit --include includePattern --exclude excludePattern --message ' . escapeshellarg('text') . ' --logfile ' . escapeshellarg('logfile') . ' --date ' . escapeshellarg('date') . ' --user ' . escapeshellarg('user') . ' --subrepos '; |
42
|
|
|
|
43
|
|
|
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { |
44
|
|
|
$file = str_replace("'", '"', $file); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
$this->assertSame($file, implode(' ', $commitCmd->getFile())); |
48
|
|
|
$this->assertSame($expected . $file, $commitCmd->asString()); |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|