-
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
117 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 array getInclude() | ||
* @method void addInclude(string $pattern) | ||
* @method array getExclude() | ||
* @method void addExclude(string $pattern) | ||
*/ | ||
class ForgetCommand extends AbstractCommand | ||
{ | ||
/** | ||
* Available arguments for this command. | ||
* | ||
* @var array $arguments | ||
*/ | ||
protected $arguments = array( | ||
'file' => array() | ||
); | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @var mixed $options | ||
*/ | ||
protected $options = array( | ||
'--include' => array(), | ||
'--exclude' => array() | ||
); | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getFile() | ||
{ | ||
return $this->arguments['file']; | ||
} | ||
|
||
/** | ||
* @param string $file | ||
* | ||
* @return void | ||
*/ | ||
public function addFile($file) | ||
{ | ||
$this->arguments['file'][] = escapeshellarg($file); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function __toString() | ||
{ | ||
return sprintf( | ||
"%s%s %s", | ||
$this->name, | ||
$this->assembleOptionString(), | ||
implode(' ', $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,40 @@ | ||
<?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 ForgetCommandTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @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()); | ||
} | ||
} |