[Console] fixed new ArgvInput method

This commit is contained in:
Kris Wallsmith 2011-02-10 16:53:18 -08:00 committed by Fabien Potencier
parent c2e4ec44a8
commit 36ff9abe67
2 changed files with 20 additions and 1 deletions

View File

@ -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);
}
}
}

View File

@ -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