Permalink
Browse files

fix that argument with 0 as value will stop parsing args, tests added

  • Loading branch information...
1 parent c81fe62 commit 828117583f0f136dd2e48d7faa95583906509246 @ceeram ceeram committed Jan 17, 2012
@@ -467,7 +467,7 @@ public function parse($argv, $command = null) {
}
$params = $args = array();
$this->_tokens = $argv;
- while ($token = array_shift($this->_tokens)) {
+ while (($token = array_shift($this->_tokens)) !== null) {
if (substr($token, 0, 2) == '--') {
$params = $this->_parseLongOption($token, $params);
} elseif (substr($token, 0, 1) == '-') {
@@ -351,6 +351,19 @@ public function testParseArgumentTooMany() {
}
/**
+ * test parsing arguments with 0 value.
+ *
+ * @return void
+ */
+ public function testParseArgumentZero() {
+ $parser = new ConsoleOptionParser('test', false);
+
+ $expected = array('one', 'two', 0, 'after', 'zero');
+ $result = $parser->parse($expected);
+ $this->assertEquals($expected, $result[1], 'Arguments are not as expected');
+ }
+
+/**
* test that when there are not enough arguments an exception is raised
*
* @expectedException ConsoleException

0 comments on commit 8281175

Please sign in to comment.