Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
added test to verify ArgvInput->parse() failure with array input defi…
…nition
  • Loading branch information
Degory Valentine committed Feb 28, 2011
commit c3676e1764fae0d725041ad71dcf65c69eaeb87e
2 changes: 1 addition & 1 deletion src/Symfony/Component/Console/Input/ArgvInput.php
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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