This PR was merged into the 2.3 branch.
Discussion
----------
[Intl] fixed datetime test as described in #9455
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #9455
| License | MIT
| Doc PR | -
Commits
-------
056d836
[Intl] fixed datetime test as described in #9455
This commit is contained in:
commit
2ef5e61888
@ -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));
|
||||
|
Reference in New Issue
Block a user