mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
fix that argument with 0 as value will stop parsing args, tests added
This commit is contained in:
parent
c81fe6249d
commit
828117583f
2 changed files with 14 additions and 1 deletions
|
@ -467,7 +467,7 @@ class ConsoleOptionParser {
|
|||
}
|
||||
$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) == '-') {
|
||||
|
|
|
@ -350,6 +350,19 @@ class ConsoleOptionParserTest extends CakeTestCase {
|
|||
$result = $parser->parse(array('one', 'two', 'three'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue