From 2ce9f389de980cbd50df5d6ba5e54346d9fe0854 Mon Sep 17 00:00:00 2001 From: Alex Denvir Date: Tue, 4 Dec 2012 15:19:14 +0000 Subject: [PATCH 1/2] Cast $step to float, as fmod returns a float (string !== float) --- library/Zend/Validator/Step.php | 2 +- tests/ZendTest/Validator/StepTest.php | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/library/Zend/Validator/Step.php b/library/Zend/Validator/Step.php index 6478ce98c9e..a6d3b14c2f0 100644 --- a/library/Zend/Validator/Step.php +++ b/library/Zend/Validator/Step.php @@ -98,7 +98,7 @@ public function getBaseValue() */ public function setStep($step) { - $this->step = $step; + $this->step = (float) $step; return $this; } diff --git a/tests/ZendTest/Validator/StepTest.php b/tests/ZendTest/Validator/StepTest.php index 6ea70358820..3031ee85aed 100644 --- a/tests/ZendTest/Validator/StepTest.php +++ b/tests/ZendTest/Validator/StepTest.php @@ -190,4 +190,18 @@ public function testEqualsMessageTemplates() $this->assertAttributeEquals($validator->getOption('messageTemplates'), 'messageTemplates', $validator); } + + public function testSetStepFloat() + { + $step = 0.01; + $this->_validator->setStep($step); + $this->assertAttributeSame($step, 'step', $this->_validator); + } + + public function testSetStepString() + { + $step = '0.01'; + $this->_validator->setStep($step); + $this->assertAttributeSame((float) $step, 'step', $this->_validator); + } } From 989d6e16d9577ee3597141b63f6f6f1c7c1a3712 Mon Sep 17 00:00:00 2001 From: Alex Denvir Date: Tue, 4 Dec 2012 15:29:06 +0000 Subject: [PATCH 2/2] Trailing space in test --- tests/ZendTest/Validator/StepTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ZendTest/Validator/StepTest.php b/tests/ZendTest/Validator/StepTest.php index 3031ee85aed..e349e5826a5 100644 --- a/tests/ZendTest/Validator/StepTest.php +++ b/tests/ZendTest/Validator/StepTest.php @@ -190,14 +190,14 @@ public function testEqualsMessageTemplates() $this->assertAttributeEquals($validator->getOption('messageTemplates'), 'messageTemplates', $validator); } - + public function testSetStepFloat() { $step = 0.01; $this->_validator->setStep($step); $this->assertAttributeSame($step, 'step', $this->_validator); } - + public function testSetStepString() { $step = '0.01';