Browse Source

[Locale] Fixed failing StubNumberFormatterTest when intl extension is not loaded

Bernhard Schussek 14 years ago
parent
commit
33e70673c2

+ 5 - 1
tests/Symfony/Tests/Component/Locale/Stub/StubNumberFormatterTest.php

@@ -188,11 +188,15 @@ class StubNumberFormatterTest extends LocaleTestCase
 
 
     public function formatCurrencyWithCurrencyStyleSwissRoundingProvider()
     public function formatCurrencyWithCurrencyStyleSwissRoundingProvider()
     {
     {
+        $chf = 'CHF';
+
         // The currency symbol was updated from 4.2 to the 4.4 version. The ICU CLDR data was updated in 2010-03-03,
         // The currency symbol was updated from 4.2 to the 4.4 version. The ICU CLDR data was updated in 2010-03-03,
         // the 4.2 release is from 2009-05-08 and the 4.4 from 2010-03-17. It's ugly we want to compare if the
         // the 4.2 release is from 2009-05-08 and the 4.4 from 2010-03-17. It's ugly we want to compare if the
         // stub implementation is behaving like the intl one
         // stub implementation is behaving like the intl one
         // http://bugs.icu-project.org/trac/changeset/27776/icu/trunk/source/data/curr/en.txt
         // http://bugs.icu-project.org/trac/changeset/27776/icu/trunk/source/data/curr/en.txt
-        $chf = $this->isLowerThanIcuVersion('4.4') ? 'Fr.' : 'CHF';
+        if ($this->isIntlExtensionLoaded() && $this->isLowerThanIcuVersion('4.4')) {
+            $chf = 'Fr.';
+        }
 
 
         return array(
         return array(
             array(100, 'CHF', $chf, '%s100.00'),
             array(100, 'CHF', $chf, '%s100.00'),

+ 4 - 0
tests/Symfony/Tests/Component/Locale/TestCase.php

@@ -78,6 +78,10 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase
             return self::$icuVersion;
             return self::$icuVersion;
         }
         }
 
 
+        if (!$this->isIntlExtensionLoaded()) {
+            throw new \RuntimeException('The intl extension is not available');
+        }
+
         ob_start();
         ob_start();
         phpinfo(INFO_MODULES);
         phpinfo(INFO_MODULES);
         $output = ob_get_clean();
         $output = ob_get_clean();