From efd1f87665345571774dd6ac24b33dd8a570f56e Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 1 Oct 2012 22:49:04 +0700 Subject: [PATCH 1/3] fix redundance errors --- library/Zend/Validator/Date.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Zend/Validator/Date.php b/library/Zend/Validator/Date.php index c2b12ca54ed..905d5a63b86 100644 --- a/library/Zend/Validator/Date.php +++ b/library/Zend/Validator/Date.php @@ -128,7 +128,7 @@ public function isValid($value) // and still return a DateTime object $errors = DateTime::getLastErrors(); - if (false === $date || $errors['warning_count'] > 0) { + if ($errors['warning_count'] > 0) { $this->error(self::INVALID_DATE); return false; } From 710e125aed944bd1f23c02e0aa7fac5565d215e5 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 1 Oct 2012 22:49:04 +0700 Subject: [PATCH 2/3] fix redundance errors --- library/Zend/Validator/Date.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Zend/Validator/Date.php b/library/Zend/Validator/Date.php index c2b12ca54ed..905d5a63b86 100644 --- a/library/Zend/Validator/Date.php +++ b/library/Zend/Validator/Date.php @@ -128,7 +128,7 @@ public function isValid($value) // and still return a DateTime object $errors = DateTime::getLastErrors(); - if (false === $date || $errors['warning_count'] > 0) { + if ($errors['warning_count'] > 0) { $this->error(self::INVALID_DATE); return false; } From 8f35cd3b9a4872fa19213611394a96058d041eae Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Wed, 3 Oct 2012 12:18:50 +0700 Subject: [PATCH 3/3] unit test for datevalidator twice --- tests/ZendTest/Form/View/Helper/FormRowTest.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/ZendTest/Form/View/Helper/FormRowTest.php b/tests/ZendTest/Form/View/Helper/FormRowTest.php index 8c7ae052e98..b84674907cf 100644 --- a/tests/ZendTest/Form/View/Helper/FormRowTest.php +++ b/tests/ZendTest/Form/View/Helper/FormRowTest.php @@ -305,4 +305,18 @@ public function testShowErrorInRadio() $markup = $this->helper->__invoke($element); $this->assertContains('
  • Error message
', $markup); } + + public function testErrorShowTwice() + { + $element = new Element\Date('birth'); + $element->setFormat('Y-m-d'); + $element->setValue('2010-13-13'); + + $validator = new \Zend\Validator\Date(); + $validator->isValid($element->getValue()); + $element->setMessages($validator->getMessages()); + + $markup = $this->helper->__invoke($element); + $this->assertEquals(2, count(explode("
  • The input does not appear to be a valid date
", $markup))); + } }