diff --git a/src/Page/Mvc.php b/src/Page/Mvc.php index a7509c0..206780a 100644 --- a/src/Page/Mvc.php +++ b/src/Page/Mvc.php @@ -197,7 +197,7 @@ public function getHref() ); } - if ($this->useRouteMatch()) { + if ($this->useRouteMatch() && $this->getRouteMatch()) { $rmParams = $this->getRouteMatch()->getParams(); if (isset($rmParams[ModuleRouteListener::ORIGINAL_CONTROLLER])) { diff --git a/test/Page/MvcTest.php b/test/Page/MvcTest.php index 4747afe..b3908a3 100644 --- a/test/Page/MvcTest.php +++ b/test/Page/MvcTest.php @@ -68,6 +68,19 @@ public function testHrefGeneratedByRouterRequiresNoRoute() $this->assertEquals('/news/view', $page->getHref()); } + public function testHrefRouteMatchEnabledWithoutRouteMatchObject() + { + $page = new Page\Mvc(array( + 'label' => 'foo', + 'route' => 'test/route', + 'use_route_match' => true + )); + $router = $this->getMock('\Zend\Mvc\Router\Http\TreeRouteStack'); + $router->expects($this->once())->method('assemble')->will($this->returnValue('/test/route')); + $page->setRouter($router); + $this->assertEquals('/test/route', $page->getHref()); + } + public function testHrefGeneratedIsRouteAware() { $page = new Page\Mvc(array(