Skip to content
Browse files

Fix zero value in argument

  • Loading branch information...
1 parent e09ba97 commit 54b63e1aa743e1c120796dde4e6b704bb01a0657 @blanchonvincent committed Mar 4, 2013
Showing with 9 additions and 5 deletions.
  1. +4 −3 library/Zend/Mvc/Router/Console/Simple.php
  2. +5 −2 tests/ZendTest/Mvc/Router/Console/SimpleTest.php
View
7 library/Zend/Mvc/Router/Console/Simple.php
@@ -557,10 +557,11 @@ public function match(Request $request, $pathOffset = null)
*/
$positional = $named = array();
foreach ($this->parts as &$part) {
- if ($part['positional'])
+ if ($part['positional']) {
$positional[] = &$part;
- else
+ } else {
$named[] = &$part;
+ }
}
/**
@@ -651,7 +652,7 @@ public function match(Request $request, $pathOffset = null)
/**
* Try to retrieve value if it is expected
*/
- if (!$value && $part['hasValue']) {
+ if (null === $value && $part['hasValue']) {
if ($x < count($params)+1) {
// retrieve value from adjacent param
$value = $params[$x];
View
7 tests/ZendTest/Mvc/Router/Console/SimpleTest.php
@@ -2,7 +2,6 @@
namespace ZendTest\Mvc\Router\Console;
use PHPUnit_Framework_TestCase as TestCase;
-use Zend\Http\Request;
use Zend\Console\Request as ConsoleRequest;
use Zend\Mvc\Router\Console\Simple;
use ZendTest\Mvc\Router\FactoryTester;
@@ -28,6 +27,11 @@ public static function routeProvider()
array('--foo','--bar'),
array('foo' => true, 'bar' => true)
),
+ 'mandatory-long-flag-match-with-zero-value' => array(
+ '--foo=',
+ array('--foo=0'),
+ array('foo' => 0)
+ ),
'mandatory-long-flag-mixed-order-match' => array(
'--foo --bar',
array('--bar','--foo'),
@@ -583,7 +587,6 @@ public static function routeProvider()
'baz' => true
)
),
-
/*'combined-2' => array(
'--foo --bar',
array('a','b', 'c', '--foo', '--bar'),

0 comments on commit 54b63e1

Please sign in to comment.
Something went wrong with that request. Please try again.