From 79695037b0f949a1bee5ddfcdd5123c07a00cfad Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 2 Sep 2015 17:00:49 +0200 Subject: [PATCH] [Intl] Fix test --- .../DateFormat/TimeZoneTransformer.php | 2 +- .../Intl/NumberFormatter/NumberFormatter.php | 6 +++--- .../DateFormatter/AbstractIntlDateFormatterTest.php | 13 ++++++++++--- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Component/Intl/DateFormatter/DateFormat/TimeZoneTransformer.php b/src/Symfony/Component/Intl/DateFormatter/DateFormat/TimeZoneTransformer.php index adca3eeb7d..6f9c0d5a02 100644 --- a/src/Symfony/Component/Intl/DateFormatter/DateFormat/TimeZoneTransformer.php +++ b/src/Symfony/Component/Intl/DateFormatter/DateFormat/TimeZoneTransformer.php @@ -29,7 +29,7 @@ class TimeZoneTransformer extends Transformer { $timeZone = substr($dateTime->getTimezone()->getName(), 0, 3); - if (!in_array($timeZone, array('Etc', 'UTC'))) { + if (!in_array($timeZone, array('Etc', 'UTC', 'GMT'))) { throw new NotImplementedException('Time zone different than GMT or UTC is not supported as a formatting output.'); } diff --git a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php index 07c8e84c86..0ee222ee50 100644 --- a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php +++ b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php @@ -773,7 +773,7 @@ class NumberFormatter * @param mixed $value The value to be converted * @param int $type The type to convert. Can be TYPE_DOUBLE (float) or TYPE_INT32 (int) * - * @return int|float The converted value + * @return int|float|false The converted value */ private function convertValueDataType($value, $type) { @@ -793,7 +793,7 @@ class NumberFormatter * * @param mixed $value The value to be converted * - * @return int The converted value + * @return int|false The converted value */ private function getInt32Value($value) { @@ -809,7 +809,7 @@ class NumberFormatter * * @param mixed $value The value to be converted * - * @return int|float The converted value + * @return int|float|false The converted value * * @see https://bugs.php.net/bug.php?id=59597 Bug #59597 */ diff --git a/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php b/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php index 259f5e5d9d..0603394fe1 100644 --- a/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php @@ -392,14 +392,21 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase ); } - public function testFormatWithDateTimeZone() + public function testFormatWithDateTimeZoneGmt() { if (PHP_VERSION_ID < 50500) { $this->markTestSkipped('Only in PHP 5.5+ IntlDateFormatter allows to use DateTimeZone objects.'); } - if (defined('HHVM_VERSION_ID')) { - $this->markTestSkipped('This test cannot work on HHVM. See https://github.com/facebook/hhvm/issues/5875 for the issue.'); + $formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, new \DateTimeZone('GMT'), IntlDateFormatter::GREGORIAN, 'zzzz'); + + $this->assertEquals('GMT', $formatter->format(0)); + } + + public function testFormatWithDateTimeZoneGmtOffset() + { + if (defined('HHVM_VERSION_ID') || PHP_VERSION_ID <= 50509) { + $this->markTestSkipped('DateTimeZone GMT offsets are supported since 5.5.10. See https://github.com/facebook/hhvm/issues/5875 for HHVM.'); } $formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, new \DateTimeZone('GMT+03:00'), IntlDateFormatter::GREGORIAN, 'zzzz');