From 056d83646f817bfe9a55d552ae2625bd47abf28f Mon Sep 17 00:00:00 2001 From: Andrey Esaulov Date: Thu, 14 Nov 2013 12:38:26 +0100 Subject: [PATCH] [Intl] fixed datetime test as described in #9455 --- .../AbstractIntlDateFormatterTest.php | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php b/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php index 759dbc8e20..9578d1f033 100644 --- a/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php @@ -22,6 +22,12 @@ use Symfony\Component\Intl\Intl; */ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase { + + protected function setUp() + { + \Locale::setDefault('en'); + } + /** * When a time zone is not specified, it uses the system default however it returns null in the getter method * @covers Symfony\Component\Intl\DateFormatter\IntlDateFormatter::getTimeZoneId @@ -376,7 +382,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase $formatter->setPattern('yyyy-MM-dd HH:mm:ss'); $this->assertEquals( - $this->getDateTime(0)->format('Y-m-d H:i:s'), + $this->getDateTime(0, 'UTC')->format('Y-m-d H:i:s'), $formatter->format(0) ); } @@ -394,7 +400,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase $formatter->setPattern('yyyy-MM-dd HH:mm:ss'); $this->assertEquals( - $this->getDateTime(0)->format('Y-m-d H:i:s'), + $this->getDateTime(0, 'Europe/London')->format('Y-m-d H:i:s'), $formatter->format(0) ); @@ -417,7 +423,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase $formatter->setPattern('yyyy-MM-dd HH:mm:ss'); $this->assertEquals( - $this->getDateTime(0)->format('Y-m-d H:i:s'), + $this->getDateTime(0, 'Europe/London')->format('Y-m-d H:i:s'), $formatter->format(0) ); @@ -865,14 +871,8 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase return $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, 'UTC', IntlDateFormatter::GREGORIAN, $pattern); } - protected function getDateTime($timestamp = null) + protected function getDateTime($timestamp, $timeZone) { - if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { - $timeZone = date_default_timezone_get(); - } else { - $timeZone = getenv('TZ') ?: 'UTC'; - } - $dateTime = new \DateTime(); $dateTime->setTimestamp(null === $timestamp ? time() : $timestamp); $dateTime->setTimeZone(new \DateTimeZone($timeZone));