/**
  * @test
  */
 public function rootCommand()
 {
     /* @var $rootCmd \Siad007\VersionControl\HG\Command\RootCommand */
     $rootCmd = Factory::getInstance('root');
     $expected = 'hg root';
     $this->assertSame($expected, $rootCmd->asString());
 }
 /**
  * @test
  */
 public function commitCommand()
 {
     $commitCmd = Factory::createCommit();
     $commitCmd->addFile('C:\\xampp\\file1\\');
     $commitCmd->addFile('C:\\xampp\\file2\\');
     $commitCmd->setAddremove(true);
     $commitCmd->setCloseBranch(true);
     $commitCmd->setAmend(true);
     $commitCmd->setSecret(true);
     $commitCmd->setEdit(true);
     $commitCmd->addInclude('includePattern');
     $commitCmd->addExclude('excludePattern');
     $commitCmd->setMessage('text');
     $commitCmd->setLogfile('logfile');
     $commitCmd->setDate('date');
     $commitCmd->setUser('user');
     $commitCmd->setSubrepos(true);
     $file = '\'C:\\xampp\\file1\\\' \'C:\\xampp\\file2\\\'';
     $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 ';
     if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
         $file = str_replace("'", '"', $file);
     }
     $this->assertSame($file, implode(' ', $commitCmd->getFile()));
     $this->assertSame($expected . $file, $commitCmd->asString());
 }
 /**
  * @test
  */
 public function summaryCommand()
 {
     $summaryCmd = Factory::createSummary();
     $summaryCmd->setRemote(true);
     $expected = 'hg summary --remote';
     $this->assertSame($expected, $summaryCmd->asString());
 }
 /**
  * @test
  */
 public function manifestCommand()
 {
     $manifestCmd = Factory::createManifest();
     $manifestCmd->setRev('test');
     $manifestCmd->setAll(true);
     $expected = 'hg manifest --rev ' . escapeshellarg('test') . ' --all';
     $this->assertSame($expected, $manifestCmd->asString());
 }
 /**
  * @test
  */
 public function branchesCommand()
 {
     $branchesCmd = Factory::createBranches();
     $branchesCmd->setClosed(true);
     $branchesCmd->setActive(true);
     $expected = 'hg branches --active --closed';
     $this->assertSame($expected, $branchesCmd->asString());
 }
 /**
  * @test
  */
 public function cloneCommandWithoutSource()
 {
     /* @var $cloneCmd \Siad007\VersionControl\HG\Command\CloneCommand */
     $cloneCmd = Factory::getInstance('clone');
     $cloneCmd->setUncompressed(true);
     $cloneCmd->setInsecure(true);
     $cloneCmd->asString();
     $this->assertError("No source directory given.", E_USER_ERROR);
 }
 /**
  * @test
  */
 public function mergeCommand()
 {
     $mergeCmd = Factory::createMerge();
     $mergeCmd->setRev('revision');
     $mergeCmd->setTool('testtool');
     $mergeCmd->setPreview(true);
     $expected = 'hg merge --rev ' . escapeshellarg('revision') . ' --preview --tool ' . escapeshellarg('testtool');
     $this->assertSame($expected, $mergeCmd->asString());
 }
 /**
  * @test
  */
 public function pathsCommand()
 {
     /* @var $pathsCmd \Siad007\VersionControl\HG\Command\PathsCommand */
     $pathsCmd = Factory::getInstance('paths');
     $pathsCmd->setName('test');
     $expected = 'hg paths test';
     $this->assertSame('test', $pathsCmd->getName());
     $this->assertSame($expected, $pathsCmd->asString());
 }
 /**
  * @test
  */
 public function headsCommand()
 {
     $headsCmd = Factory::createHeads();
     $headsCmd->setTemplate('template');
     $headsCmd->setClosed(true);
     $headsCmd->setRev('startrev');
     $headsCmd->setTopo(true);
     $expected = 'hg heads --rev ' . escapeshellarg('startrev') . ' --topo --closed --template ' . escapeshellarg('template');
     $this->assertSame($expected, $headsCmd->asString());
 }
 /**
  * @test
  */
 public function phaseCommand()
 {
     $phaseCmd = Factory::createPhase();
     $phaseCmd->setPublic(true);
     $phaseCmd->setForce(true);
     $phaseCmd->setVerbose(true);
     $phaseCmd->setEncoding('UTF-8');
     $expected = 'hg phase --verbose --encoding ' . escapeshellarg('UTF-8') . ' --public --force';
     $this->assertSame($expected, $phaseCmd->asString());
 }
 /**
  * @test
  */
 public function configCommand()
 {
     $configCmd = Factory::createConfig()->addName('test')->setUntrusted(true)->setEdit(true)->setLocal(true)->setGlobal(true);
     $name = '\'test\'';
     $expected = 'hg config --untrusted --edit --local --global ';
     if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
         $name = str_replace("'", '"', $name);
     }
     $this->assertSame($name, implode(' ', $configCmd->getName()));
     $this->assertSame($expected . $name, $configCmd->asString());
 }
 /**
  * @test
  */
 public function bisecCommand()
 {
     $bisecCmd = Factory::createBisec();
     $bisecCmd->setReset(true);
     $bisecCmd->setGood(true);
     $bisecCmd->setBad(true);
     $bisecCmd->setSkip(true);
     $bisecCmd->setExtend(true);
     $expected = 'hg bisec --reset --good --bad --skip --extend';
     $this->assertSame($expected, $bisecCmd->asString());
 }
 /**
  * @test
  */
 public function updateCommandWithBranch()
 {
     $updateCmd = Factory::createUpdate();
     $updateCmd->setClean(true);
     $updateCmd->setCheck(true);
     $updateCmd->setDate('date');
     $updateCmd->setRev('rev');
     $updateCmd->setBranch('dev');
     $expected = 'hg update --clean --check --date ' . escapeshellarg('date') . ' --rev ' . escapeshellarg('rev') . ' ' . escapeshellarg('dev');
     $this->assertSame($expected, $updateCmd->asString());
 }
 /**
  * @test
  */
 public function logCommand()
 {
     $logCmd = Factory::createLog();
     $logCmd->setFile('C:\\xampp\\file\\')->addInclude('includePattern')->addExclude('excludePattern')->setFollow(true)->setCopies(true);
     $file = '\'C:\\xampp\\file\\\'';
     $expected = 'hg log --follow --copies --include includePattern --exclude excludePattern ';
     if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
         $file = str_replace("'", '"', $file);
     }
     $this->assertSame($file, $logCmd->getFile());
     $this->assertSame($expected . $file, $logCmd->asString());
 }
 /**
  * @test
  */
 public function identifyCommand()
 {
     $identifyCmd = Factory::createIdentify();
     $identifyCmd->setSource('C:\\xampp\\source\\');
     $identifyCmd->setNum(true);
     $identifyCmd->setInsecure(true);
     $source = '\'C:\\xampp\\source\\\'';
     $expected = "hg identify --num --insecure ";
     if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
         $source = str_replace("'", '"', $source);
     }
     $this->assertSame($source, $identifyCmd->getSource());
     $this->assertSame($expected . $source, $identifyCmd->asString());
 }
 /**
  * @test
  */
 public function branchCommand()
 {
     $branchCmd = Factory::createBranch();
     $branchCmd->setName('test');
     $branchCmd->setClean(true);
     $branchCmd->setForce(true);
     $name = '\'test\'';
     $expected = 'hg branch --force --clean ';
     if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
         $name = str_replace("'", '"', $name);
     }
     $this->assertSame($name, $branchCmd->getName());
     $this->assertSame($expected . $name, $branchCmd->asString());
 }
 /**
  * @test
  */
 public function parentsCommand()
 {
     $parentsCmd = Factory::createParents();
     $parentsCmd->setFile('C:\\xampp\\file\\');
     $parentsCmd->setRev('revision');
     $parentsCmd->setTemplate('template');
     $file = '\'C:\\xampp\\file\\\'';
     $expected = 'hg parents --rev ' . escapeshellarg('revision') . ' --template ' . escapeshellarg('template') . ' ';
     if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
         $file = str_replace("'", '"', $file);
     }
     $this->assertSame($file, $parentsCmd->getFile());
     $this->assertSame($expected . $file, $parentsCmd->asString());
 }
 /**
  * @test
  */
 public function unbundleCommand()
 {
     $unbundleCmd = Factory::createUnbundle();
     $unbundleCmd->addFile('C:\\xampp\\file1\\');
     $unbundleCmd->addFile('C:\\xampp\\file2\\');
     $unbundleCmd->setUpdate(true);
     $file = '\'C:\\xampp\\file1\\\' \'C:\\xampp\\file2\\\'';
     $expected = 'hg unbundle --update ';
     if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
         $file = str_replace("'", '"', $file);
     }
     $this->assertSame($file, implode(' ', $unbundleCmd->getFile()));
     $this->assertSame($expected . $file, $unbundleCmd->asString());
 }
 /**
  * @test
  */
 public function statusCommand()
 {
     $statusCmd = Factory::createStatus();
     $statusCmd->addFile('C:\\xampp\\file\\');
     $statusCmd->addInclude('includePattern');
     $statusCmd->addExclude('excludePattern');
     $statusCmd->setSubrepos(true);
     $file = '\'C:\\xampp\\file\\\'';
     $expected = 'hg status --include includePattern --exclude excludePattern --subrepos ';
     if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
         $file = str_replace("'", '"', $file);
     }
     $this->assertSame($file, implode(' ', $statusCmd->getFile()));
     $this->assertSame($expected . $file, $statusCmd->asString());
 }
 /**
  * @test
  */
 public function forgetCommand()
 {
     $forgetCmd = Factory::createForget();
     $forgetCmd->addFile('C:\\xampp\\file1\\');
     $forgetCmd->addFile('C:\\xampp\\file2\\');
     $forgetCmd->addInclude('includePattern');
     $forgetCmd->addExclude('excludePattern');
     $file = '\'C:\\xampp\\file1\\\' \'C:\\xampp\\file2\\\'';
     $expected = 'hg forget --include includePattern --exclude excludePattern ';
     if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
         $file = str_replace("'", '"', $file);
     }
     $this->assertSame($file, implode(' ', $forgetCmd->getFile()));
     $this->assertSame($expected . $file, $forgetCmd->asString());
 }
 /**
  * @test
  */
 public function locateCommand()
 {
     $locateCmd = Factory::createLocate();
     $locateCmd->addPattern('test');
     $locateCmd->setFullpath(true);
     $locateCmd->addInclude('includePattern');
     $locateCmd->addExclude('excludePattern');
     $pattern = '\'test\'';
     $expected = 'hg locate --fullpath --include includePattern --exclude excludePattern ';
     if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
         $pattern = str_replace("'", '"', $pattern);
     }
     $this->assertSame($pattern, implode(' ', $locateCmd->getPattern()));
     $this->assertSame($expected . $pattern, $locateCmd->asString());
 }
 /**
  * @test
  */
 public function bookmarksCommand()
 {
     $bookmarksCmd = Factory::createBookmarks();
     $bookmarksCmd->addName('test1');
     $bookmarksCmd->addName('test2');
     $bookmarksCmd->setRev('revision');
     $bookmarksCmd->setForce(true);
     $bookmarksCmd->setRename('name');
     $name = '\'test1\' \'test2\'';
     $expected = 'hg bookmarks --force --rev ' . escapeshellarg('revision') . ' --rename ' . escapeshellarg('name') . ' ';
     if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
         $name = str_replace("'", '"', $name);
     }
     $this->assertSame($name, implode(' ', $bookmarksCmd->getName()));
     $this->assertSame($expected . $name, $bookmarksCmd->asString());
 }
 /**
  * @test
  */
 public function initCommand()
 {
     $initCmd = Factory::createInit();
     $initCmd->setDestination('C:\\xampp\\dest\\');
     $initCmd->setSsh('testSSH');
     $initCmd->setInsecure(true);
     $initCmd->setVerbose(true);
     $initCmd->setEncoding('UTF-8');
     $destination = '\'C:\\xampp\\dest\\\'';
     $expected = 'hg init --verbose --encoding ' . escapeshellarg('UTF-8') . ' --ssh ' . escapeshellarg('testSSH') . ' --insecure ';
     if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
         $destination = str_replace("'", '"', $destination);
     }
     $this->assertSame($destination, $initCmd->getDestination());
     $this->assertSame($expected . $destination, $initCmd->asString());
 }
 /**
  * @test
  */
 public function archiveCommand()
 {
     $archiveCmd = Factory::createArchive();
     $archiveCmd->setDestination('C:\\xampp\\dest\\');
     $archiveCmd->addInclude('includePattern');
     $archiveCmd->addExclude('excludePattern');
     $archiveCmd->setSubrepos(true);
     $archiveCmd->setNoDecode(true);
     $destination = '\'C:\\xampp\\dest\\\'';
     $expected = 'hg archive --no-decode --subrepos --include includePattern --exclude excludePattern ';
     if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
         $destination = str_replace("'", '"', $destination);
     }
     $this->assertSame($destination, $archiveCmd->getDestination());
     $this->assertSame($expected . $destination, $archiveCmd->asString());
 }
 /**
  * @test
  */
 public function pushCommand()
 {
     /* @var $pushCmd \Siad007\VersionControl\HG\Command\PushCommand */
     $pushCmd = Factory::getInstance('push');
     $pushCmd->setDestination('C:\\xampp\\dest\\');
     $pushCmd->setSsh('testSSH');
     $pushCmd->setInsecure(true);
     $pushCmd->setVerbose(true);
     $pushCmd->setEncoding('UTF-8');
     $destination = '\'C:\\xampp\\dest\\\'';
     $expected = 'hg push --verbose --encoding ' . escapeshellarg('UTF-8') . ' --ssh ' . escapeshellarg('testSSH') . ' --insecure ';
     if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
         $destination = str_replace("'", '"', $destination);
     }
     $this->assertSame($destination, $pushCmd->getDestination());
     $this->assertSame($expected . $destination, $pushCmd->asString());
 }
 /**
  * @test
  */
 public function addremoveCommand()
 {
     $addremoveCmd = Factory::createAddremove();
     $addremoveCmd->addFile('C:\\xampp\\file1\\');
     $addremoveCmd->addFile('C:\\xampp\\file2\\');
     $addremoveCmd->setSimilarity('50');
     $addremoveCmd->addInclude('includePattern');
     $addremoveCmd->addExclude('excludePattern');
     $addremoveCmd->setDryRun(true);
     $file = '\'C:\\xampp\\file1\\\' \'C:\\xampp\\file2\\\'';
     $expected = 'hg addremove --similarity ' . escapeshellarg('50') . ' --include includePattern --exclude excludePattern --dry-run ';
     if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
         $file = str_replace("'", '"', $file);
     }
     $this->assertSame($file, implode(' ', $addremoveCmd->getFile()));
     $this->assertSame($expected . $file, $addremoveCmd->asString());
 }
 /**
  * @test
  */
 public function catCommand()
 {
     $catCmd = Factory::createCat();
     $catCmd->addFile('C:\\xampp\\file1\\');
     $catCmd->addFile('C:\\xampp\\file2\\');
     $catCmd->setRev('revision');
     $catCmd->setOutput('output');
     $catCmd->addInclude('includePattern');
     $catCmd->addExclude('excludePattern');
     $catCmd->setDecode(true);
     $file = '\'C:\\xampp\\file1\\\' \'C:\\xampp\\file2\\\'';
     $expected = 'hg cat --output ' . escapeshellarg('output') . ' --rev ' . escapeshellarg('revision') . ' --decode --include includePattern --exclude excludePattern ';
     if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
         $file = str_replace("'", '"', $file);
     }
     $this->assertSame($file, implode(' ', $catCmd->getFile()));
     $this->assertSame($expected . $file, $catCmd->asString());
 }
 /**
  * @test
  */
 public function tagCommand()
 {
     $tagCmd = Factory::createTag();
     $tagCmd->addName('rev');
     $tagCmd->addName('rev2');
     $tagCmd->setForce(true);
     $tagCmd->setLocal(true);
     $tagCmd->setRev('test');
     $tagCmd->setRemove(true);
     $tagCmd->setEdit(true);
     $tagCmd->setMessage('text');
     $tagCmd->setDate('date');
     $tagCmd->setUser('user');
     $name = 'rev rev2';
     $expected = 'hg tag --force --local --rev ' . escapeshellarg('test') . ' --remove --edit --message ' . escapeshellarg('text') . ' --date ' . escapeshellarg('date') . ' --user ' . escapeshellarg('user') . ' ';
     $this->assertSame($name, implode(' ', $tagCmd->getName()));
     $this->assertSame($expected . $name, $tagCmd->asString());
 }
 /**
  * @test
  */
 public function backoutCommand()
 {
     $backoutCmd = Factory::createBackout();
     $backoutCmd->setRevision('revision');
     $backoutCmd->setMerge(true);
     $backoutCmd->setTool('tool');
     $backoutCmd->addInclude('includePattern');
     $backoutCmd->addExclude('excludePattern');
     $backoutCmd->setMessage('text');
     $backoutCmd->setLogfile('logfile');
     $backoutCmd->setDate('date');
     $backoutCmd->setUser('user');
     $revision = '\'revision\'';
     $expected = 'hg backout --merge --tool ' . escapeshellarg('tool') . ' --include includePattern --exclude excludePattern --message ' . escapeshellarg('text') . ' --logfile ' . escapeshellarg('logfile') . ' --date ' . escapeshellarg('date') . ' --user ' . escapeshellarg('user') . ' ';
     if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
         $revision = str_replace("'", '"', $revision);
     }
     $this->assertSame($revision, $backoutCmd->getRevision());
     $this->assertSame($expected . $revision, $backoutCmd->asString());
 }
 /**
  * @test
  */
 public function revertCommand()
 {
     $revertCmd = Factory::createRevert();
     $revertCmd->addName('name1');
     $revertCmd->addName('name2');
     $revertCmd->setRev('revision');
     $revertCmd->setDate('date');
     $revertCmd->setAll(true);
     $revertCmd->setNoBackup(true);
     $revertCmd->addInclude('includePattern');
     $revertCmd->addExclude('excludePattern');
     $revertCmd->setDryRun(true);
     $name = '\'name1\' \'name2\'';
     $expected = 'hg revert --all --date ' . escapeshellarg('date') . ' --rev ' . escapeshellarg('revision') . ' --no-backup --include includePattern --exclude excludePattern --dry-run ';
     if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
         $name = str_replace("'", '"', $name);
     }
     $this->assertSame($name, implode(' ', $revertCmd->getName()));
     $this->assertSame($expected . $name, $revertCmd->asString());
 }