From 8e3222bf0253f70ec7c2ac93c6ec07ff91490a34 Mon Sep 17 00:00:00 2001 From: Stefano Torresi Date: Thu, 6 Mar 2014 14:24:22 +0100 Subject: [PATCH] add test for Menu helper liActiveClass optional parameter --- .../View/Helper/Navigation/MenuTest.php | 59 ++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/tests/ZendTest/View/Helper/Navigation/MenuTest.php b/tests/ZendTest/View/Helper/Navigation/MenuTest.php index 609d1fb6977..cdc1bd55c39 100644 --- a/tests/ZendTest/View/Helper/Navigation/MenuTest.php +++ b/tests/ZendTest/View/Helper/Navigation/MenuTest.php @@ -9,6 +9,8 @@ namespace ZendTest\View\Helper\Navigation; +use Zend\View\Helper\Navigation\Menu; + /** * Tests Zend_View_Helper_Navigation_Menu * @@ -27,7 +29,7 @@ class MenuTest extends AbstractTest /** * View helper * - * @var Zend_View_Helper_Navigation_Menu + * @var Menu */ protected $_helper; @@ -593,6 +595,61 @@ public function testRenderDeepestMenuWithPageClassToLi() $this->assertEquals(trim($expected), trim($actual)); } + public function testActiveClassParameterIsOptional() + { + $container = new \Zend\Navigation\Navigation(array( + array( + 'label' => 'page 1', + 'uri' => '', + 'active' => true, + 'pages' => array( + array( + 'label' => 'subpage 1', + 'uri' => '', + 'active' => true, + ) + ) + ), + array( + 'label' => 'page 2', + 'uri' => '', + ) + )); + $renderNormalMenuMethod = new \ReflectionMethod(get_class($this->_helper), 'renderNormalMenu'); + $renderNormalMenuMethod->setAccessible(true); + $renderDeepestMenuMethod = new \ReflectionMethod(get_class($this->_helper), 'renderDeepestMenu'); + $renderDeepestMenuMethod->setAccessible(true); + + // note, keys are here just for readability. order is what matters + $markup = $renderNormalMenuMethod->invokeArgs($this->_helper, array( + 'container' => $container, + 'ulClass' => 'navigation', + 'indent' => '', + 'minDepth' => null, + 'maxDepth' => null, + 'onlyActiveBranch' => true, + 'escapeLabels' => true, + 'addClassToListItem' => false + ) + ); + + $this->assertContains(sprintf('
  • ', $this->_helper->getLiActiveClass() ), $markup); + + // note, keys are here just for readability. order is what matters + $markup = $renderDeepestMenuMethod->invokeArgs($this->_helper, array( + 'container' => $container, + 'ulClass' => 'navigation', + 'indent' => '', + 'minDepth' => null, + 'maxDepth' => null, + 'escapeLabels' => true, + 'addClassToListItem' => false + ) + ); + + $this->assertContains(sprintf('
  • ', $this->_helper->getLiActiveClass() ), $markup); + } + /** * Returns the contens of the expected $file, normalizes newlines * @param string $file