Skip to content
Browse files

Merge branch 'hotfix/3345'

Close #3345
  • Loading branch information...
2 parents 7c7a463 + 28f4394 commit e8698c308db98e4397cffc113bb2d4220122eb41 @weierophinney weierophinney committed
Showing with 24 additions and 2 deletions.
  1. +4 −2 library/Zend/Form/View/Helper/FormRow.php
  2. +20 −0 tests/ZendTest/Form/View/Helper/FormRowTest.php
View
6 library/Zend/Form/View/Helper/FormRow.php
@@ -160,7 +160,7 @@ public function render(ElementInterface $element)
* @param bool $renderErrors
* @return string|FormRow
*/
- public function __invoke(ElementInterface $element = null, $labelPosition = null, $renderErrors = true)
+ public function __invoke(ElementInterface $element = null, $labelPosition = null, $renderErrors = null)
{
if (!$element) {
return $this;
@@ -170,7 +170,9 @@ public function __invoke(ElementInterface $element = null, $labelPosition = null
$this->setLabelPosition($labelPosition);
}
- $this->setRenderErrors($renderErrors);
+ if($renderErrors !== null){
+ $this->setRenderErrors($renderErrors);
+ }
return $this->render($element);
}
View
20 tests/ZendTest/Form/View/Helper/FormRowTest.php
@@ -319,4 +319,24 @@ public function testErrorShowTwice()
$markup = $this->helper->__invoke($element);
$this->assertEquals(2, count(explode("<ul><li>The input does not appear to be a valid date</li></ul>", $markup)));
}
+
+ public function testInvokeWithNoRenderErrors()
+ {
+ $mock = $this->getMock(get_class($this->helper), array('setRenderErrors'));
+ $mock->expects($this->never())
+ ->method('setRenderErrors');
+
+ $mock->__invoke(new Element('foo'));
+ }
+
+ public function testInvokeWithRenderErrorsTrue()
+ {
+ $mock = $this->getMock(get_class($this->helper), array('setRenderErrors'));
+ $mock->expects($this->once())
+ ->method('setRenderErrors')
+ ->with(true);
+
+ $mock->__invoke(new Element('foo'), null, true);
+ }
+
}

0 comments on commit e8698c3

Please sign in to comment.
Something went wrong with that request. Please try again.