Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Commit

Permalink
Merge 429717b into 0e4e808
Browse files Browse the repository at this point in the history
  • Loading branch information
kusmierz committed Jan 26, 2015
2 parents 0e4e808 + 429717b commit 104997f
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
8 changes: 5 additions & 3 deletions library/Zend/Mvc/Router/Http/Chain.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,13 @@ public function assemble(array $params = array(), array $options = array())

$this->assembledParams = array();

end($this->routes);
$lastRouteKey = key($this->routes);
$routes = ArrayUtils::iteratorToArray($this->routes);

end($routes);
$lastRouteKey = key($routes);
$path = '';

foreach ($this->routes as $key => $route) {
foreach ($routes as $key => $route) {
$chainOptions = $options;
$hasChild = isset($options['has_child']) ? $options['has_child'] : false;

Expand Down
47 changes: 47 additions & 0 deletions tests/ZendTest/Mvc/Router/Http/ChainTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,35 @@ public static function getRoute()
);
}

public static function getRouteWithOptionalParam()
{
$routePlugins = new RoutePluginManager();

return new Chain(
array(
array(
'type' => 'Zend\Mvc\Router\Http\Segment',
'options' => array(
'route' => '/:controller',
'defaults' => array(
'controller' => 'foo',
),
),
),
array(
'type' => 'Zend\Mvc\Router\Http\Segment',
'options' => array(
'route' => '[/:bar]',
'defaults' => array(
'bar' => 'bar',
),
),
),
),
$routePlugins
);
}

public static function routeProvider()
{
return array(
Expand Down Expand Up @@ -79,6 +108,24 @@ public static function routeProvider()
'bar' => 'baz',
),
),
'optional-parameter' => array(
self::getRouteWithOptionalParam(),
'/foo/baz',
null,
array(
'controller' => 'foo',
'bar' => 'baz',
),
),
'optional-parameter-empty' => array(
self::getRouteWithOptionalParam(),
'/foo',
null,
array(
'controller' => 'foo',
'bar' => 'bar',
),
),
);
}

Expand Down

0 comments on commit 104997f

Please sign in to comment.