[Console] fixed ArrayInput, if array contains 0 key.
This commit is contained in:
parent
917067e940
commit
a642e4b9f1
@ -100,8 +100,10 @@ class ArrayInput extends Input
|
||||
$values = (array) $values;
|
||||
|
||||
foreach ($this->parameters as $k => $v) {
|
||||
if (is_int($k) && in_array($v, $values)) {
|
||||
return true;
|
||||
if (is_int($k)) {
|
||||
if (in_array($v, $values)) {
|
||||
return true;
|
||||
}
|
||||
} elseif (in_array($k, $values)) {
|
||||
return $v;
|
||||
}
|
||||
|
@ -38,6 +38,15 @@ class ArrayInputTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertTrue($input->hasParameterOption('--foo'), '->hasParameterOption() returns true if an option is present in the passed parameters');
|
||||
}
|
||||
|
||||
public function testGetParameterOption()
|
||||
{
|
||||
$input = new ArrayInput(array('name' => 'Fabien', '--foo' => 'bar'));
|
||||
$this->assertEquals('bar', $input->getParameterOption('--foo'), '->getParameterOption() returns the option of specified name');
|
||||
|
||||
$input = new ArrayInput(array('Fabien', '--foo' => 'bar'));
|
||||
$this->assertEquals('bar', $input->getParameterOption('--foo'), '->getParameterOption() returns the option of specified name');
|
||||
}
|
||||
|
||||
public function testParseArguments()
|
||||
{
|
||||
$input = new ArrayInput(array('name' => 'foo'), new InputDefinition(array(new InputArgument('name'))));
|
||||
|
Reference in New Issue
Block a user