Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/Preflight/ArgsRemapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public function __construct($remapOptions, $remapCommandAliases)
public function remap($argv)
{
$result = [];
$sawCommmand = false;
$sawCommand = false;
foreach ($argv as $arg) {
$arg = $this->checkRemap($arg, $sawCommmand);
$arg = $this->checkRemap($arg, $sawCommand);
if (isset($arg)) {
$result[] = $arg;
}
Expand All @@ -41,12 +41,13 @@ public function remap($argv)
* Check to see if the provided single arg needs to be remapped. If
* it does, then the remapping is performed.
*
* @param stinrg $arg One arguent to inspect
* @param string $arg One argument to inspect
* @param string $sawCommand True if drush command was found
* @return string The altered argument
*/
protected function checkRemap($arg, &$sawCommmand)
protected function checkRemap($arg, &$sawCommand)
{
if (!$sawCommmand && ctype_alpha($arg[0])) {
if (!$sawCommand && ctype_alpha($arg[0])) {
$sawCommand = true;
return $this->remapCommandAlias($arg);
}
Expand Down
43 changes: 43 additions & 0 deletions tests/ArgsRemapperTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace Unish;

use \Drush\Preflight\ArgsRemapper;

/**
* Tests the Arguments Remapper.
*
* @group base
*/
class ArgsRemapperTest extends CommandUnishTestCase
{

/**
* @covers argsRemapper::ArgsRemapper
* @dataProvider argsProvider
*/
public function testCommandAliases($argv, $expected)
{
$remapOptions = [];
$remapCommandAliases = [
'en' => 'pm:enable'
];
$sut = new ArgsRemapper($remapOptions, $remapCommandAliases);
$result = $sut->remap($argv);

$this->assertEquals($expected, $result);
}

/**
* Provides argumens for ::ArgsRemapper
*/
public function argsProvider()
{
return [
[
['en', 'en'],
['pm:enable', 'en'],
],
];
}
}