-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
/** | ||
* VersionControl_HG | ||
* Simple OO implementation for Mercurial. | ||
* | ||
* PHP Version 5.4 | ||
* | ||
* @copyright 2014 Siad Ardroumli | ||
* @license http://www.opensource.org/licenses/mit-license.php MIT | ||
* @link http://siad007.github.io/versioncontrol_hg | ||
*/ | ||
|
||
namespace Siad007\VersionControl\HG\Command; | ||
|
||
/** | ||
* Simple OO implementation for Mercurial. | ||
* | ||
* @author Siad Ardroumli <[email protected]> | ||
* | ||
* @method string getRev() | ||
* @method void setRev(string $revision) | ||
* @method string getTemplate() | ||
* @method void setTemplate(string $template) | ||
*/ | ||
class ParentsCommand extends AbstractCommand | ||
{ | ||
/** | ||
* Available arguments for this command. | ||
* | ||
* @var array $arguments | ||
*/ | ||
protected $arguments = array( | ||
'file' => '' | ||
); | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @var mixed $options | ||
*/ | ||
protected $options = array( | ||
'--rev' => '', | ||
'--template' => '' | ||
); | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getFile() | ||
{ | ||
return $this->arguments['file']; | ||
} | ||
|
||
/** | ||
* @param string $file | ||
* | ||
* @return void | ||
*/ | ||
public function setFile($file) | ||
{ | ||
$this->arguments['file'] = escapeshellarg($file); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function __toString() | ||
{ | ||
return sprintf( | ||
"%s%s %s", | ||
$this->name, | ||
$this->assembleOptionString(), | ||
$this->arguments['file'] | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
/** | ||
* VersionControl_HG | ||
* Simple OO implementation for Mercurial. | ||
* | ||
* PHP Version 5.4 | ||
* | ||
* @copyright 2014 Siad Ardroumli | ||
* @license http://www.opensource.org/licenses/mit-license.php MIT | ||
* @link http://siad007.github.io/versioncontrol_hg | ||
*/ | ||
|
||
namespace Siad007\VersionControl\HG\Tests\Command; | ||
|
||
use Siad007\VersionControl\HG\Factory; | ||
|
||
class ParentsCommandTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @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 revision --template template '; | ||
|
||
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { | ||
$file = str_replace("'", '"', $file); | ||
} | ||
|
||
$this->assertSame($file, $parentsCmd->getFile()); | ||
$this->assertSame($expected . $file, $parentsCmd->asString()); | ||
} | ||
} |