diff --git a/tests/Moment/WeekdayTest.php b/tests/Moment/WeekdayTest.php new file mode 100644 index 0000000..8d854f1 --- /dev/null +++ b/tests/Moment/WeekdayTest.php @@ -0,0 +1,93 @@ +weekday()); + } + + /** + * @return array + */ + public static function dataProviderForTime(): array + { + return [ + 'same weekday in UTC' => [ + Weekday::SATURDAY, + Moment::fromString('2022-10-08 15:00:00'), + ], + 'weekday adapted due to weekday zone difference' => [ + Weekday::SATURDAY, + Moment::fromStringInTimeZone('2022-10-08 00:00:00', new \DateTimeZone('Europe/Berlin')) + ->toTimeZone(new \DateTimeZone('Europe/Berlin')), + ], + ]; + } + + /** + * @test + * + * @dataProvider dataProviderForTimeInTimeZone + * + * @covers ::weekdayInTimeZone + */ + public function weekday_in_weekday_zone_works( + Weekday $expectedResult, + Moment $dateTime, + \DateTimeZone $weekdayZone, + ): void { + // -- Act & Assert + self::assertEquals($expectedResult, $dateTime->weekdayInTimeZone($weekdayZone)); + } + + /** + * @return array + */ + public static function dataProviderForTimeInTimeZone(): array + { + return [ + 'same weekday in UTC' => [ + Weekday::SATURDAY, + Moment::fromString('2022-10-08 15:00:00'), + new \DateTimeZone('UTC'), + ], + 'adapting weekday for two hours through timezone difference' => [ + Weekday::SUNDAY, + Moment::fromString('2022-10-08 23:00:00'), + new \DateTimeZone('Europe/Berlin'), + ], + 'same weekday when timezone was used for creation of datetime' => [ + Weekday::SATURDAY, + Moment::fromStringInTimeZone('2022-10-08 15:00:00', new \DateTimeZone('Europe/Berlin')), + new \DateTimeZone('Europe/Berlin'), + ], + ]; + } +}