Skip to content

Commit

Permalink
add test for Menu helper liActiveClass optional parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefano Torresi committed Mar 6, 2014
1 parent d02d04d commit 8e3222b
Showing 1 changed file with 58 additions and 1 deletion.
59 changes: 58 additions & 1 deletion tests/ZendTest/View/Helper/Navigation/MenuTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

namespace ZendTest\View\Helper\Navigation;

use Zend\View\Helper\Navigation\Menu;

/**
* Tests Zend_View_Helper_Navigation_Menu
*
Expand All @@ -27,7 +29,7 @@ class MenuTest extends AbstractTest
/**
* View helper
*
* @var Zend_View_Helper_Navigation_Menu
* @var Menu
*/
protected $_helper;

Expand Down Expand Up @@ -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('<li class="%s">', $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('<li class="%s">', $this->_helper->getLiActiveClass() ), $markup);
}

/**
* Returns the contens of the expected $file, normalizes newlines
* @param string $file
Expand Down

0 comments on commit 8e3222b

Please sign in to comment.