Skip to content

Commit 057e861

Browse files
Degory Valentinefabpot
authored andcommitted
added test to verify ArgvInput->parse() failure with array input definition
1 parent 0306c9a commit 057e861

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/Symfony/Component/Console/Input/ArgvInput.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ protected function parseArgument($token)
164164

165165
// unexpected argument
166166
} else {
167-
throw new RuntimeException('Too many arguments.');
167+
throw new \RuntimeException('Too many arguments.');
168168
}
169169
}
170170

tests/Symfony/Tests/Component/Console/Input/ArgvInputTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,14 @@ public function testParser()
135135
$input = new TestInput(array('cli.php', '-fbbar'));
136136
$input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputOption('bar', 'b', InputOption::VALUE_OPTIONAL))));
137137
$this->assertEquals(array('foo' => 'bbar', 'bar' => null), $input->getOptions(), '->parse() parses short options when they are aggregated as a single one and one of them takes a value');
138+
139+
try {
140+
$input = new TestInput(array('cli.php', 'foo', 'bar', 'baz', 'bat'));
141+
$input->bind(new InputDefinition(array(new InputArgument('name', InputArgument::IS_ARRAY))));
142+
$this->assertEquals(array('name' => array('foo', 'bar', 'baz', 'bat')), $input->getArguments(), '->parse() parses array arguments');
143+
} catch (\RuntimeException $e) {
144+
$this->assertNotEquals('Too many arguments.', $e->getMessage(), '->parse() parses array arguments');
145+
}
138146
}
139147

140148
public function testGetFirstArgument()

0 commit comments

Comments
 (0)