From dbde06a3fa797c1f560a32ffe9e643b678f6f03a Mon Sep 17 00:00:00 2001 From: Frank de Jonge Date: Wed, 8 Jun 2022 14:23:59 +0200 Subject: [PATCH] Ensure the timezone use is guarded by a test. --- src/Fixtures/ClassWithFormattedDateTimeInput.php | 2 +- src/ObjectHydrationTestCase.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Fixtures/ClassWithFormattedDateTimeInput.php b/src/Fixtures/ClassWithFormattedDateTimeInput.php index 60b0d16..28bf00a 100644 --- a/src/Fixtures/ClassWithFormattedDateTimeInput.php +++ b/src/Fixtures/ClassWithFormattedDateTimeInput.php @@ -11,7 +11,7 @@ final class ClassWithFormattedDateTimeInput { public function __construct( - #[CastToDateTimeImmutable('!d-m-Y')] + #[CastToDateTimeImmutable('!d-m-Y', 'Europe/Amsterdam')] public DateTimeImmutable $date ) { } diff --git a/src/ObjectHydrationTestCase.php b/src/ObjectHydrationTestCase.php index 40b61ba..8349ef3 100644 --- a/src/ObjectHydrationTestCase.php +++ b/src/ObjectHydrationTestCase.php @@ -227,6 +227,7 @@ public function hydrating_a_class_with_a_formatted_date(): void self::assertInstanceOf(ClassWithFormattedDateTimeInput::class, $object); self::assertEquals('1987-11-24 00:00:00', $object->date->format('Y-m-d H:i:s')); + self::assertEquals('Europe/Amsterdam', $object->date->getTimezone()->getName()); } /**