public function ArgvInputTest::testParseArrayOption in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/symfony/console/Tests/Input/ArgvInputTest.php \Symfony\Component\Console\Tests\Input\ArgvInputTest::testParseArrayOption()
File
- vendor/
symfony/ console/ Tests/ Input/ ArgvInputTest.php, line 214
Class
Namespace
Symfony\Component\Console\Tests\InputCode
public function testParseArrayOption() {
$input = new ArgvInput(array(
'cli.php',
'--name=foo',
'--name=bar',
'--name=baz',
));
$input
->bind(new InputDefinition(array(
new InputOption('name', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY),
)));
$this
->assertEquals(array(
'name' => array(
'foo',
'bar',
'baz',
),
), $input
->getOptions(), '->parse() parses array options ("--option=value" syntax)');
$input = new ArgvInput(array(
'cli.php',
'--name',
'foo',
'--name',
'bar',
'--name',
'baz',
));
$input
->bind(new InputDefinition(array(
new InputOption('name', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY),
)));
$this
->assertEquals(array(
'name' => array(
'foo',
'bar',
'baz',
),
), $input
->getOptions(), '->parse() parses array options ("--option value" syntax)');
$input = new ArgvInput(array(
'cli.php',
'--name=foo',
'--name=bar',
'--name=',
));
$input
->bind(new InputDefinition(array(
new InputOption('name', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY),
)));
$this
->assertSame(array(
'name' => array(
'foo',
'bar',
null,
),
), $input
->getOptions(), '->parse() parses empty array options as null ("--option=value" syntax)');
$input = new ArgvInput(array(
'cli.php',
'--name',
'foo',
'--name',
'bar',
'--name',
'--anotherOption',
));
$input
->bind(new InputDefinition(array(
new InputOption('name', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY),
new InputOption('anotherOption', null, InputOption::VALUE_NONE),
)));
$this
->assertSame(array(
'name' => array(
'foo',
'bar',
null,
),
'anotherOption' => true,
), $input
->getOptions(), '->parse() parses empty array options as null ("--option value" syntax)');
}