Index: tests/Zend/Validate/FloatTest.php =================================================================== --- tests/Zend/Validate/FloatTest.php (revision 20460) +++ tests/Zend/Validate/FloatTest.php (working copy) @@ -54,9 +54,31 @@ */ public function setUp() { + $this->_locale = setlocale(LC_ALL, 0); //backup locale + + require_once 'Zend/Registry.php'; + if (Zend_Registry::isRegistered('Zend_Locale')) { + Zend_Registry::getInstance()->offsetUnset('Zend_Locale'); + } + $this->_validator = new Zend_Validate_Float(); } + public function tearDown() + { + //restore locale + if (is_string($this->_locale) && strpos($this->_locale, ';')) { + $locales = array(); + foreach (explode(';', $this->_locale) as $l) { + $tmp = explode('=', $l); + $locales[$tmp[0]] = $tmp[1]; + } + setlocale(LC_ALL, $locales); + return; + } + setlocale(LC_ALL, $this->_locale); + } + /** * Ensures that the validator follows expected behavior * @@ -114,4 +136,31 @@ $valid = new Zend_Validate_Float(); $this->assertTrue($valid->isValid('123,456')); } + + /** + * @ZF-7987 + */ + public function testNoZendLocaleButPhpLocale() + { + setlocale(LC_ALL, 'de'); + $valid = new Zend_Validate_Float(); + $this->assertTrue($valid->isValid('123,456')); + } + + public function testLocaleDeFloatType() + { + $this->_validator->setLocale('de'); + $this->assertEquals('de', $this->_validator->getLocale()); + $this->assertEquals(true, $this->_validator->isValid(10.5)); + } + + /** + * @ZF-7987 + */ + public function testPhpLocaleDeFloatType() + { + setlocale(LC_ALL, 'de'); + $valid = new Zend_Validate_Float(); + $this->assertTrue($valid->isValid(10.5)); + } }