ImportCommandTest::importCommand()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 27

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 27
rs 9.488
c 0
b 0
f 0
cc 2
nc 2
nop 0
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 ImportCommandTest extends \PHPUnit_Framework_TestCase
18
{
19
    /**
20
     * @test
21
     */
22
    public function importCommand()
23
    {
24
        $importCmd = Factory::createImport();
25
        $importCmd->addPatch('patch1');
26
        $importCmd->addPatch('patch2');
27
        $importCmd->setStrip('num');
28
        $importCmd->setEdit(true);
29
        $importCmd->setNoCommit(true);
30
        $importCmd->setBypass(true);
31
        $importCmd->setExact(true);
32
        $importCmd->setImportBranch(true);
33
        $importCmd->setMessage('text');
34
        $importCmd->setLogfile('logfile');
35
        $importCmd->setDate('date');
36
        $importCmd->setUser('user');
37
        $importCmd->setSimilarity('similarity');
38
39
        $patch = '\'patch1\' \'patch2\'';
40
        $expected = 'hg import --strip ' . escapeshellarg('num') . ' --edit --no-commit --bypass --exact --import-branch --message ' . escapeshellarg('text') . ' --logfile ' . escapeshellarg('logfile') . ' --date ' . escapeshellarg('date') . ' --user ' . escapeshellarg('user') . ' --similarity ' . escapeshellarg('similarity') . ' ';
41
42
        if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
43
            $patch = str_replace("'", '"', $patch);
44
        }
45
46
        $this->assertSame($patch, implode(' ', $importCmd->getPatch()));
47
        $this->assertSame($expected . $patch, $importCmd->asString());
48
    }
49
}
50