From d64b4d990a3b9e8ba7bd416858efc29692c165f0 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 8 Sep 2014 20:11:03 +0700 Subject: [PATCH] Fixes #6647 --- library/Zend/I18n/Validator/Float.php | 2 ++ tests/ZendTest/I18n/Validator/FloatTest.php | 22 +++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/library/Zend/I18n/Validator/Float.php b/library/Zend/I18n/Validator/Float.php index af1460898cb..a2ded7fb098 100644 --- a/library/Zend/I18n/Validator/Float.php +++ b/library/Zend/I18n/Validator/Float.php @@ -162,6 +162,7 @@ public function isValid($value) //We have seperators, and they are flipped. i.e. 2.000,000 for en-US if ($groupSeparatorPosition && $decSeparatorPosition && $groupSeparatorPosition > $decSeparatorPosition) { + $this->error(self::NOT_FLOAT); return false; } @@ -237,6 +238,7 @@ public function isValid($value) return true; } + $this->error(self::NOT_FLOAT); return false; } } diff --git a/tests/ZendTest/I18n/Validator/FloatTest.php b/tests/ZendTest/I18n/Validator/FloatTest.php index d418a76a70e..42a09dfa43d 100644 --- a/tests/ZendTest/I18n/Validator/FloatTest.php +++ b/tests/ZendTest/I18n/Validator/FloatTest.php @@ -220,4 +220,26 @@ public function testEqualsMessageTemplates() $validator = $this->validator; $this->assertAttributeEquals($validator->getOption('messageTemplates'), 'messageTemplates', $validator); } + + /** + * @group ZF2-6647 + * @dataProvider notFloatProvider + */ + public function testNotFloat($value) + { + $this->assertFalse($this->validator->isValid($value)); + + $message = $this->validator->getMessages(); + $this->assertContains('does not appear to be a float', $message['notFloat']); + } + + public function notFloatProvider() + { + return array( + array( + 'hello', + 2.000,000 + ), + ); + } }