[Console] fixed new ArgvInput method
This commit is contained in:
parent
c2e4ec44a8
commit
36ff9abe67
|
@ -276,7 +276,7 @@ class ArgvInput extends Input
|
|||
if (false !== $pos = strpos($token, '=')) {
|
||||
return substr($token, $pos + 1);
|
||||
} else {
|
||||
return array_shift($this->tokens);
|
||||
return array_shift($tokens);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -157,6 +157,25 @@ class ArgvInputTest extends \PHPUnit_Framework_TestCase
|
|||
$input = new TestInput(array('cli.php', 'foo'));
|
||||
$this->assertFalse($input->hasParameterOption('--foo'), '->hasParameterOption() returns false if the given short option is not in the raw input');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideGetParameterOptionValues
|
||||
*/
|
||||
public function testGetParameterOptionEqualSign($argv, $key, $expected)
|
||||
{
|
||||
$input = new ArgvInput($argv);
|
||||
$this->assertEquals($expected, $input->getParameterOption($key), '->getParameterOption() returns the expected value');
|
||||
}
|
||||
|
||||
public function provideGetParameterOptionValues()
|
||||
{
|
||||
return array(
|
||||
array(array('app/console', 'foo:bar', '-e', 'dev'), '-e', 'dev'),
|
||||
array(array('app/console', 'foo:bar', '--env=dev'), '--env', 'dev'),
|
||||
array(array('app/console', 'foo:bar', '-e', 'dev'), array('-e', '--env'), 'dev'),
|
||||
array(array('app/console', 'foo:bar', '--env=dev'), array('-e', '--env'), 'dev'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class TestInput extends ArgvInput
|
||||
|
|
Reference in New Issue