소스 검색

[Locale][Windows] Fixing tests for old ICU version (default in php.net packages)

Pascal Borreli 14 년 전
부모
커밋
8a82aee56f

+ 3 - 0
tests/Symfony/Tests/Component/Locale/Stub/StubIntlDateFormatterTest.php

@@ -67,6 +67,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase
     public function testFormatIntl($pattern, $timestamp, $expected)
     {
         $this->skipIfIntlExtensionIsNotLoaded();
+        $this->skipIfICUVersionIsTooOld();
         $formatter = $this->createIntlFormatter($pattern);
         $this->assertSame($expected, $formatter->format($timestamp));
     }
@@ -354,6 +355,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase
     public function testFormatWithDefaultTimezoneIntl()
     {
         $this->skipIfIntlExtensionIsNotLoaded();
+        $this->skipIfICUVersionIsTooOld();
         $formatter = new \IntlDateFormatter('en', StubIntlDateFormatter::MEDIUM, StubIntlDateFormatter::SHORT);
         $formatter->setPattern('yyyy-MM-dd HH:mm:ss');
 
@@ -670,6 +672,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase
     public function testParseDifferencesIntl($pattern, $value, $stubExpected, $intlExpected)
     {
         $this->skipIfIntlExtensionIsNotLoaded();
+        $this->skipIfICUVersionIsTooOld();
         $formatter = $this->createIntlFormatter($pattern);
         $this->assertSame($intlExpected, $formatter->parse($value));
     }

+ 3 - 0
tests/Symfony/Tests/Component/Locale/Stub/StubNumberFormatterTest.php

@@ -134,6 +134,7 @@ class StubNumberFormatterTest extends LocaleTestCase
     public function testFormatCurrencyWithCurrencyStyleIntl($value, $currency, $expected)
     {
         $this->skipIfIntlExtensionIsNotLoaded();
+        $this->skipIfICUVersionIsTooOld();
         $formatter = $this->getIntlFormatterWithCurrencyStyle();
         $this->assertEquals($expected, $formatter->formatCurrency($value, $currency));
     }
@@ -181,6 +182,7 @@ class StubNumberFormatterTest extends LocaleTestCase
     public function testFormatCurrencyWithCurrencyStyleSwissRoundingIntl($value, $currency, $symbol, $expected)
     {
         $this->skipIfIntlExtensionIsNotLoaded();
+        $this->skipIfICUVersionIsTooOld();
         $formatter = $this->getIntlFormatterWithCurrencyStyle();
         $this->assertEquals(sprintf($expected, $symbol), $formatter->formatCurrency($value, $currency));
     }
@@ -660,6 +662,7 @@ class StubNumberFormatterTest extends LocaleTestCase
     public function testParseIntl($value, $expected, $message = '')
     {
         $this->skipIfIntlExtensionIsNotLoaded();
+        $this->skipIfICUVersionIsTooOld();
         $formatter = $this->getIntlFormatterWithDecimalStyle();
         $parsedValue = $formatter->parse($value, \NumberFormatter::TYPE_DOUBLE);
         $this->assertSame($expected, $parsedValue, $message);

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

@@ -37,6 +37,15 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase
         }
     }
 
+    protected function skipIfICUVersionIsTooOld()
+    {
+        if ($this->isLowerThanIcuVersion('4.0')) {
+            $this->markTestSkipped(
+              'Please upgrade ICU version to 4+'
+            );
+        }
+    }
+
     protected function isGreaterOrEqualThanIcuVersion($version)
     {
         $version = $this->normalizeIcuVersion($version);