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 adca3eeb7dcea..6f9c0d5a02bb5 100644 --- a/src/Symfony/Component/Intl/DateFormatter/DateFormat/TimeZoneTransformer.php +++ b/src/Symfony/Component/Intl/DateFormatter/DateFormat/TimeZoneTransformer.php @@ -29,7 +29,7 @@ public function format(\DateTime $dateTime, $length) { $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 07c8e84c861bf..0ee222ee50fd6 100644 --- a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php +++ b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php @@ -773,7 +773,7 @@ private function isInitializedAttribute($attr) * @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 @@ private function convertValueDataType($value, $type) * * @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 @@ private function getInt32Value($value) * * @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 259f5e5d9d5c4..0603394fe1f6d 100644 --- a/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php @@ -392,14 +392,21 @@ public function testFormatWithConstructorTimezone() ); } - 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'); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy