/** * Tests that hrefs are generated correctly using the URL helper when * page has a route specified * */ public function testHrefGeneratedIsRouteAware() { $page = new Zym_Navigation_Page_Mvc(array('label' => 'foo', 'action' => 'myaction', 'controller' => 'mycontroller', 'route' => 'myroute', 'params' => array('page' => 1337))); $this->_front->getRouter()->addRoute('myroute', new Zend_Controller_Router_Route('lolcat/:action/:page', array('module' => 'default', 'controller' => 'foobar', 'action' => 'bazbat', 'page' => 1))); $this->assertEquals('/lolcat/myaction/1337', $page->getHref()); }
<?php // the following route is added to the ZF router Zend_Controller_Front::getInstance()->getRouter()->addRoute('article_view', new Zend_Controller_Router_Route('a/:id', array('module' => 'news', 'controller' => 'article', 'action' => 'view', 'id' => null))); // a page is created with a 'route' option $page = new Zym_Navigation_Page_Mvc(array('label' => 'A news article', 'route' => 'article_view', 'params' => array('id' => 42))); // returns: /a/42 $page->getHref();