Skip to content

Commit

Permalink
added test to verify ArgvInput->parse() failure with array input defi…
Browse files Browse the repository at this point in the history
…nition
  • Loading branch information
Degory Valentine authored and fabpot committed Feb 28, 2011
1 parent 0306c9a commit 057e861
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Symfony/Component/Console/Input/ArgvInput.php
Expand Up @@ -164,7 +164,7 @@ protected function parseArgument($token)

// unexpected argument
} else {
throw new RuntimeException('Too many arguments.');
throw new \RuntimeException('Too many arguments.');
}
}

Expand Down
8 changes: 8 additions & 0 deletions tests/Symfony/Tests/Component/Console/Input/ArgvInputTest.php
Expand Up @@ -135,6 +135,14 @@ public function testParser()
$input = new TestInput(array('cli.php', '-fbbar'));
$input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputOption('bar', 'b', InputOption::VALUE_OPTIONAL))));
$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');

try {
$input = new TestInput(array('cli.php', 'foo', 'bar', 'baz', 'bat'));
$input->bind(new InputDefinition(array(new InputArgument('name', InputArgument::IS_ARRAY))));
$this->assertEquals(array('name' => array('foo', 'bar', 'baz', 'bat')), $input->getArguments(), '->parse() parses array arguments');
} catch (\RuntimeException $e) {
$this->assertNotEquals('Too many arguments.', $e->getMessage(), '->parse() parses array arguments');
}
}

public function testGetFirstArgument()
Expand Down

0 comments on commit 057e861

Please sign in to comment.