Skip to content

Commit

Permalink
Merge branch 'hotfix/2937'
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Nov 19, 2012
2 parents 510dc44 + fe9a1f7 commit f5494d4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
8 changes: 6 additions & 2 deletions library/Zend/Mvc/Controller/Plugin/Forward.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,15 @@ public function dispatch($name, array $params = null)
}
}

// Allow passing parameters to seed the RouteMatch with

// Allow passing parameters to seed the RouteMatch with & copy matched route name
if ($params !== null) {
$event->setRouteMatch(new RouteMatch($params));
$routeMatch = new RouteMatch($params);
$routeMatch->setMatchedRouteName($event->getRouteMatch()->getMatchedRouteName());
$event->setRouteMatch($routeMatch);
}


if ($this->numNestedForwards > $this->maxNestedForwards) {
throw new Exception\DomainException("Circular forwarding detected: greater than $this->maxNestedForwards nested forwards");
}
Expand Down
18 changes: 12 additions & 6 deletions tests/ZendTest/Mvc/Controller/Plugin/ForwardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ public function setUp()
$event->setApplication($mockApplication);
$event->setRequest(new Request());
$event->setResponse(new Response());
$event->setRouteMatch(new RouteMatch(array('action' => 'test')));

$routeMatch = new RouteMatch(array('action' => 'test'));
$routeMatch->setMatchedRouteName('some-route');
$event->setRouteMatch($routeMatch);

$locator = new Locator;
$locator->add('forward', function() {
Expand Down Expand Up @@ -129,17 +132,20 @@ public function testDispatchWillSeedRouteMatchWithPassedParameters()

public function testRouteMatchObjectRemainsSameFollowingForwardDispatch()
{
$routeMatch = $this->controller->getEvent()->getRouteMatch();
$matchParams = $routeMatch->getParams();
$routeMatch = $this->controller->getEvent()->getRouteMatch();
$matchParams = $routeMatch->getParams();
$matchMatchedRouteName = $routeMatch->getMatchedRouteName();
$result = $this->plugin->dispatch('forward', array(
'action' => 'test-matches',
'param1' => 'foobar',
));
$test = $this->controller->getEvent()->getRouteMatch();
$testParams = $test->getParams();
$testMatch = $this->controller->getEvent()->getRouteMatch();
$testParams = $testMatch->getParams();
$testMatchedRouteName = $testMatch->getMatchedRouteName();

$this->assertSame($routeMatch, $test);
$this->assertSame($routeMatch, $testMatch);
$this->assertEquals($matchParams, $testParams);
$this->assertEquals($matchMatchedRouteName, $testMatchedRouteName);
}

public function testAllowsPassingEmptyArrayOfRouteParams()
Expand Down

0 comments on commit f5494d4

Please sign in to comment.