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 + ), + ); + } }