From a6f1a91b1a42b9e0c9881f1b4a195b356b8d3cf9 Mon Sep 17 00:00:00 2001 From: Matt Pinkston Date: Mon, 30 Jul 2012 15:19:45 -0500 Subject: [PATCH 1/2] added test for escapeLabels --- src/Helper/Navigation/Menu.php | 12 ++---------- test/Helper/Navigation/MenuTest.php | 18 ++++++++++++++++++ .../expected/menu/escapelabels_as_false.html | 14 ++++++++++++++ 3 files changed, 34 insertions(+), 10 deletions(-) create mode 100644 test/Helper/Navigation/_files/expected/menu/escapelabels_as_false.html diff --git a/src/Helper/Navigation/Menu.php b/src/Helper/Navigation/Menu.php index 191a5fc8..72f4fb74 100644 --- a/src/Helper/Navigation/Menu.php +++ b/src/Helper/Navigation/Menu.php @@ -132,20 +132,12 @@ public function getOnlyActiveBranch() * @param bool $flag [optional] escape labels. Default is true. * @return Menu fluent interface, returns self */ - public function setEscapeLabels($flag = true) + public function escapeLabels($flag = true) { $this->escapeLabels = $flag; return $this; } - /** - * @return bool whether or not to escape labels - */ - public function getEscapeLabels() - { - return $this->escapeLabels; - } - /** * Enables/disables rendering of parents when only rendering active branch * @@ -306,7 +298,7 @@ protected function normalizeOptions(array $options = array()) } if (!isset($options['escapeLabels'])) { - $options['escapeLabels'] = $this->getEscapeLabels(); + $options['escapeLabels'] = $this->escapeLabels; } if (!isset($options['renderParents'])) { diff --git a/test/Helper/Navigation/MenuTest.php b/test/Helper/Navigation/MenuTest.php index 73abee18..cd719e9d 100644 --- a/test/Helper/Navigation/MenuTest.php +++ b/test/Helper/Navigation/MenuTest.php @@ -174,6 +174,24 @@ public function testSetUlCssClass() $this->assertEquals($expected, $this->_helper->render($this->_nav2)); } + public function testOptionEscapeLabelsAsFalse() + { + $options = array( + 'escapeLabels' => false + ); + + $container = new \Zend\Navigation\Navigation($this->_nav2->toArray()); + $container->addPage(array( + 'label' => 'Badges 1', + 'uri' => 'badges' + )); + + $expected = $this->_getExpected('menu/escapelabels_as_false.html'); + $actual = $this->_helper->renderMenu($container, $options); + + $this->assertEquals($expected, $actual); + } + public function testTranslationUsingZendTranslate() { $translator = $this->_getTranslator(); diff --git a/test/Helper/Navigation/_files/expected/menu/escapelabels_as_false.html b/test/Helper/Navigation/_files/expected/menu/escapelabels_as_false.html new file mode 100644 index 00000000..b6d17018 --- /dev/null +++ b/test/Helper/Navigation/_files/expected/menu/escapelabels_as_false.html @@ -0,0 +1,14 @@ + \ No newline at end of file From 0ebd7d3005c66e212a8f43f673fb8ae34f3af66c Mon Sep 17 00:00:00 2001 From: Matt Pinkston Date: Mon, 30 Jul 2012 15:37:32 -0500 Subject: [PATCH 2/2] Added another test to ensure labels are escaped when escapeLabels is true --- test/Helper/Navigation/MenuTest.php | 18 ++++++++++++++++++ .../expected/menu/escapelabels_as_true.html | 14 ++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 test/Helper/Navigation/_files/expected/menu/escapelabels_as_true.html diff --git a/test/Helper/Navigation/MenuTest.php b/test/Helper/Navigation/MenuTest.php index cd719e9d..6a5991b2 100644 --- a/test/Helper/Navigation/MenuTest.php +++ b/test/Helper/Navigation/MenuTest.php @@ -174,6 +174,24 @@ public function testSetUlCssClass() $this->assertEquals($expected, $this->_helper->render($this->_nav2)); } + public function testOptionEscapeLabelsAsTrue() + { + $options = array( + 'escapeLabels' => true + ); + + $container = new \Zend\Navigation\Navigation($this->_nav2->toArray()); + $container->addPage(array( + 'label' => 'Badges 1', + 'uri' => 'badges' + )); + + $expected = $this->_getExpected('menu/escapelabels_as_true.html'); + $actual = $this->_helper->renderMenu($container, $options); + + $this->assertEquals($expected, $actual); + } + public function testOptionEscapeLabelsAsFalse() { $options = array( diff --git a/test/Helper/Navigation/_files/expected/menu/escapelabels_as_true.html b/test/Helper/Navigation/_files/expected/menu/escapelabels_as_true.html new file mode 100644 index 00000000..59a633ca --- /dev/null +++ b/test/Helper/Navigation/_files/expected/menu/escapelabels_as_true.html @@ -0,0 +1,14 @@ + \ No newline at end of file