Skip to content

Commit 7969503

Browse files
[Intl] Fix test
1 parent fedbf71 commit 7969503

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

src/Symfony/Component/Intl/DateFormatter/DateFormat/TimeZoneTransformer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function format(\DateTime $dateTime, $length)
2929
{
3030
$timeZone = substr($dateTime->getTimezone()->getName(), 0, 3);
3131

32-
if (!in_array($timeZone, array('Etc', 'UTC'))) {
32+
if (!in_array($timeZone, array('Etc', 'UTC', 'GMT'))) {
3333
throw new NotImplementedException('Time zone different than GMT or UTC is not supported as a formatting output.');
3434
}
3535

src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ private function isInitializedAttribute($attr)
773773
* @param mixed $value The value to be converted
774774
* @param int $type The type to convert. Can be TYPE_DOUBLE (float) or TYPE_INT32 (int)
775775
*
776-
* @return int|float The converted value
776+
* @return int|float|false The converted value
777777
*/
778778
private function convertValueDataType($value, $type)
779779
{
@@ -793,7 +793,7 @@ private function convertValueDataType($value, $type)
793793
*
794794
* @param mixed $value The value to be converted
795795
*
796-
* @return int The converted value
796+
* @return int|false The converted value
797797
*/
798798
private function getInt32Value($value)
799799
{
@@ -809,7 +809,7 @@ private function getInt32Value($value)
809809
*
810810
* @param mixed $value The value to be converted
811811
*
812-
* @return int|float The converted value
812+
* @return int|float|false The converted value
813813
*
814814
* @see https://bugs.php.net/bug.php?id=59597 Bug #59597
815815
*/

src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,14 +392,21 @@ public function testFormatWithConstructorTimezone()
392392
);
393393
}
394394

395-
public function testFormatWithDateTimeZone()
395+
public function testFormatWithDateTimeZoneGmt()
396396
{
397397
if (PHP_VERSION_ID < 50500) {
398398
$this->markTestSkipped('Only in PHP 5.5+ IntlDateFormatter allows to use DateTimeZone objects.');
399399
}
400400

401-
if (defined('HHVM_VERSION_ID')) {
402-
$this->markTestSkipped('This test cannot work on HHVM. See https://github.com/facebook/hhvm/issues/5875 for the issue.');
401+
$formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, new \DateTimeZone('GMT'), IntlDateFormatter::GREGORIAN, 'zzzz');
402+
403+
$this->assertEquals('GMT', $formatter->format(0));
404+
}
405+
406+
public function testFormatWithDateTimeZoneGmtOffset()
407+
{
408+
if (defined('HHVM_VERSION_ID') || PHP_VERSION_ID <= 50509) {
409+
$this->markTestSkipped('DateTimeZone GMT offsets are supported since 5.5.10. See https://github.com/facebook/hhvm/issues/5875 for HHVM.');
403410
}
404411

405412
$formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, new \DateTimeZone('GMT+03:00'), IntlDateFormatter::GREGORIAN, 'zzzz');

0 commit comments

Comments
 (0)