diff --git a/tests/Zend/Locale/FormatTest.php b/tests/Zend/Locale/FormatTest.php index d42583581..ef9f6fdc3 100644 --- a/tests/Zend/Locale/FormatTest.php +++ b/tests/Zend/Locale/FormatTest.php @@ -941,20 +941,28 @@ public function testConvertPhpToIso() public function testToFloatSetlocale() { $locale = setlocale(LC_ALL, 0); - setlocale(LC_ALL, 'fr_FR@euro'); - - $locale_fr = new Zend_Locale('fr_FR'); - $locale_en = new Zend_Locale('en_US'); - $params_fr = array('precision' => 2, 'locale' => $locale_fr); - $params_en = array('precision' => 2, 'locale' => $locale_en); - $myFloat = 1234.5; - $test1 = Zend_Locale_Format::toFloat($myFloat, $params_fr); - $test2 = Zend_Locale_Format::toFloat($myFloat, $params_en); - + try { + setlocale(LC_ALL, 'fr_FR@euro'); + + $locale_fr = new Zend_Locale('fr_FR'); + $locale_en = new Zend_Locale('en_US'); + $params_fr = array('precision' => 2, 'locale' => $locale_fr); + $params_en = array('precision' => 2, 'locale' => $locale_en); + $myFloat = 1234.5; + $test1 = Zend_Locale_Format::toFloat($myFloat, $params_fr); + $test2 = Zend_Locale_Format::toFloat($myFloat, $params_en); + + $this->assertEquals("1" . self::NBSP . "234,50", $test1); + $this->assertEquals("1,234.50", $test2); + + } catch (Exception $e) { + setlocale(LC_ALL, $locale); + throw $e; + } catch (Throwable $e) { + setlocale(LC_ALL, $locale); + throw $e; + } setlocale(LC_ALL, $locale); - - $this->assertEquals("1" . self::NBSP . "234,50", $test1); - $this->assertEquals("1,234.50", $test2); } /** @@ -1115,17 +1123,19 @@ public function testToNumberWithoutFormatWithPrecision() */ public function testCheckDateFormatDoesNotEmitNoticeWhenNoOptionsAreNotProvided() { + $locale = setlocale(LC_ALL, 0); // read current locale try { - $locale = setlocale(LC_ALL, 0); // read current locale setlocale(LC_ALL, 'en_US'); // test setup Zend_Locale_Format::setOptions(array('date_format' => 'yyyy-MM-dd')); $checkDateFormat = Zend_Locale_Format::checkDateFormat('2011-10-21', array()); - setlocale(LC_ALL, $locale); // restore previous locale $this->assertTrue($checkDateFormat); } catch ( PHPUnit_Framework_Error_Notice $ex ) { + setlocale(LC_ALL, $locale); // restore previous locale + $this->fail('Zend_Locale_Format::checkDateFormat emitted unexpected E_NOTICE'); } + setlocale(LC_ALL, $locale); // restore previous locale } /**