Skip to content

Commit d9d2219

Browse files
committed
[Serializer] Replace Japan timezone with Asia/Tokyo
The PHP documentation explicitly mentions to not use this timezone and for these tests, it is irrelevant which concrete timezone is used.
1 parent 73ce8e5 commit d9d2219

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/Symfony/Component/Serializer/Tests/Normalizer/DateTimeNormalizerTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ public function testNormalizeUsingFormatPassedInConstructor()
5555

5656
public function testNormalizeUsingTimeZonePassedInConstructor()
5757
{
58-
$normalizer = new DateTimeNormalizer([DateTimeNormalizer::TIMEZONE_KEY => new \DateTimeZone('Japan')]);
58+
$normalizer = new DateTimeNormalizer([DateTimeNormalizer::TIMEZONE_KEY => new \DateTimeZone('Asia/Tokyo')]);
5959

60-
$this->assertSame('2016-12-01T00:00:00+09:00', $normalizer->normalize(new \DateTimeImmutable('2016/12/01', new \DateTimeZone('Japan'))));
60+
$this->assertSame('2016-12-01T00:00:00+09:00', $normalizer->normalize(new \DateTimeImmutable('2016/12/01', new \DateTimeZone('Asia/Tokyo'))));
6161
$this->assertSame('2016-12-01T09:00:00+09:00', $normalizer->normalize(new \DateTimeImmutable('2016/12/01', new \DateTimeZone('UTC'))));
6262
}
6363

@@ -72,9 +72,9 @@ public function testNormalizeUsingTimeZonePassedInContext($expected, $input, $ti
7272
public static function normalizeUsingTimeZonePassedInContextProvider()
7373
{
7474
yield ['2016-12-01T00:00:00+00:00', new \DateTimeImmutable('2016/12/01', new \DateTimeZone('UTC')), null];
75-
yield ['2016-12-01T00:00:00+09:00', new \DateTimeImmutable('2016/12/01', new \DateTimeZone('Japan')), new \DateTimeZone('Japan')];
76-
yield ['2016-12-01T09:00:00+09:00', new \DateTimeImmutable('2016/12/01', new \DateTimeZone('UTC')), new \DateTimeZone('Japan')];
77-
yield ['2016-12-01T09:00:00+09:00', new \DateTime('2016/12/01', new \DateTimeZone('UTC')), new \DateTimeZone('Japan')];
75+
yield ['2016-12-01T00:00:00+09:00', new \DateTimeImmutable('2016/12/01', new \DateTimeZone('Asia/Tokyo')), new \DateTimeZone('Asia/Tokyo')];
76+
yield ['2016-12-01T09:00:00+09:00', new \DateTimeImmutable('2016/12/01', new \DateTimeZone('UTC')), new \DateTimeZone('Asia/Tokyo')];
77+
yield ['2016-12-01T09:00:00+09:00', new \DateTime('2016/12/01', new \DateTimeZone('UTC')), new \DateTimeZone('Asia/Tokyo')];
7878
}
7979

8080
#[DataProvider('normalizeUsingTimeZonePassedInContextAndExpectedFormatWithMicrosecondsProvider')]
@@ -246,7 +246,7 @@ public function testDenormalize()
246246

247247
public function testDenormalizeUsingTimezonePassedInConstructor()
248248
{
249-
$timezone = new \DateTimeZone('Japan');
249+
$timezone = new \DateTimeZone('Asia/Tokyo');
250250
$expected = new \DateTimeImmutable('2016/12/01 17:35:00', $timezone);
251251
$normalizer = new DateTimeNormalizer([DateTimeNormalizer::TIMEZONE_KEY => $timezone]);
252252

@@ -277,18 +277,18 @@ public static function denormalizeUsingTimezonePassedInContextProvider()
277277
{
278278
yield 'with timezone' => [
279279
'2016/12/01 17:35:00',
280-
new \DateTimeImmutable('2016/12/01 17:35:00', new \DateTimeZone('Japan')),
281-
new \DateTimeZone('Japan'),
280+
new \DateTimeImmutable('2016/12/01 17:35:00', new \DateTimeZone('Asia/Tokyo')),
281+
new \DateTimeZone('Asia/Tokyo'),
282282
];
283283
yield 'with timezone as string' => [
284284
'2016/12/01 17:35:00',
285-
new \DateTimeImmutable('2016/12/01 17:35:00', new \DateTimeZone('Japan')),
286-
'Japan',
285+
new \DateTimeImmutable('2016/12/01 17:35:00', new \DateTimeZone('Asia/Tokyo')),
286+
'Asia/Tokyo',
287287
];
288288
yield 'with format without timezone information' => [
289289
'2016.12.01 17:35:00',
290-
new \DateTimeImmutable('2016/12/01 17:35:00', new \DateTimeZone('Japan')),
291-
new \DateTimeZone('Japan'),
290+
new \DateTimeImmutable('2016/12/01 17:35:00', new \DateTimeZone('Asia/Tokyo')),
291+
new \DateTimeZone('Asia/Tokyo'),
292292
'Y.m.d H:i:s',
293293
];
294294
yield 'ignored with format with timezone information' => [

0 commit comments

Comments
 (0)