From eacfd828f0db09c33570d08590156e4ddcf975c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Munsch?= Date: Thu, 13 Aug 2026 10:24:11 +0200 Subject: [PATCH] test(DateHelper): add integration tests for date parsing and formatting This commit introduces integration tests for the DatesHelper class, ensuring correct functionality for date parsing, range verification, and RFC3339 formatting. --- .../Shared/Helpers/DateHelperTest.php | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 tests/Integration/Shared/Helpers/DateHelperTest.php diff --git a/tests/Integration/Shared/Helpers/DateHelperTest.php b/tests/Integration/Shared/Helpers/DateHelperTest.php new file mode 100644 index 0000000..c7eb0a3 --- /dev/null +++ b/tests/Integration/Shared/Helpers/DateHelperTest.php @@ -0,0 +1,67 @@ +toBeInstanceOf(\DateTimeInterface::class) + ->and($result->format('Y-m-d'))->toBe('2025-12-25') + ->and($result->format('H:i:s'))->toBe('12:10:23'); + }); + + it('can verify a date is in between', function (): void { + // GIVEN + $now = Date::create(2025, 12, 25, 12, 0, 0); + $from = Date::createFromDate(2025, 12, 24); + $to = Date::createFromDate(2025, 12, 26); + + // WHEN + Date::setTestNow($now); + $result = DatesHelper::isIn($from, $to); + + // THEN + expect($result)->toBeTruthy(); + }); + + it('can verify a date is not in between', function (): void { + // GIVEN + $now = Date::create(2025, 12, 25, 12, 0, 0); + $from = Date::createFromDate(2025, 12, 26); + $to = Date::createFromDate(2025, 12, 27); + + // WHEN + Date::setTestNow($now); + $result = DatesHelper::isIn($from, $to); + + // THEN + expect($result)->toBeFalse(); + }); + + it('can format a date time to RFC3339', function (): void { + // GIVEN + $date = '2025-12-25 12:10:23'; + + // WHEN + $result = DatesHelper::toRfc3339($date); + + // THEN + expect($result)->toBe('2025-12-25T12:10:23+00:00'); + }); +});