Permalink
Browse files

* fix #2902

Adding tests
  • Loading branch information...
1 parent 4fdb7ff commit d4c256a6615db1237a98c443ea26c33079462b96 @cybercandyman cybercandyman committed Dec 11, 2012
Showing with 66 additions and 4 deletions.
  1. +1 −1 library/Zend/Mvc/Router/Http/Part.php
  2. +65 −3 tests/ZendTest/Mvc/Router/Http/PartTest.php
@@ -139,7 +139,7 @@ public function match(Request $request, $pathOffset = null)
$uri = $request->getUri();
$pathLength = strlen($uri->getPath());
- if ($this->mayTerminate && $nextOffset === $pathLength) {
+ if ($this->mayTerminate && $nextOffset === $pathLength && trim($uri->getQuery()) == "") {
return $match;
}
@@ -94,7 +94,38 @@ public static function getRoute()
)
);
}
-
+ public static function getRouteAlternative ()
+ {
+ $routePlugins = new RoutePluginManager();
+ $routePlugins->setInvokableClass('part', 'Zend\Mvc\Router\Http\Part');
+ return new Part(
+ array(
+ 'type' => 'Zend\Mvc\Router\Http\Segment',
+ 'options' => array(
+ 'route' => '/[:controller[/:action]]',
+ 'defaults' => array(
+ 'controller' => 'fo-fo',
+ 'action' => 'index'
+ )
+ )
+ ), true, $routePlugins,
+ array(
+ 'wildcard' => array(
+ 'type' => 'Zend\Mvc\Router\Http\Wildcard',
+ 'options' => array(
+ 'key_value_delimiter' => '/',
+ 'param_delimiter' => '/'
+ )
+ ),
+ 'query' => array(
+ 'type' => 'Zend\Mvc\Router\Http\Query',
+ 'options' => array(
+ 'key_value_delimiter' => '=',
+ 'param_delimiter' => '&'
+ )
+ )
+ ));
+ }
public static function routeProvider()
{
return array(
@@ -122,14 +153,14 @@ public static function routeProvider()
'offset-does-not-enable-partial-matching' => array(
self::getRoute(),
'/foo/foo',
- 0,
+ null,
null,
null
),
'offset-does-not-enable-partial-matching-in-child' => array(
self::getRoute(),
'/foo/bar/baz',
- 0,
+ null,
null,
null
),
@@ -175,6 +206,37 @@ public static function routeProvider()
'bat/optional',
array('foo' => 'bar')
),
+ 'simple-match' => array(
+ self::getRouteAlternative(),
+ '/',
+ null,
+ null,
+ array(
+ 'controller' => 'fo-fo',
+ 'action' => 'index'
+ )
+ ),
+ 'match-wildcard' => array(
+ self::getRouteAlternative(),
+ '/fo-fo/index/param1/value1',
+ null,
+ 'wildcard',
+ array(
+ 'controller' => 'fo-fo',
+ 'action' => 'index',
+ 'param1' => 'value1'
+ )
+ ),
+ 'match-query' => array(
+ self::getRouteAlternative(),
+ '/fo-fo/index?param1=value1',
+ 0,
+ 'query',
+ array(
+ 'controller' => 'fo-fo',
+ 'action' => 'index'
+ )
+ )
);
}

0 comments on commit d4c256a

Please sign in to comment.