From dcd85bb911e18282531a458de468d4afdf6fad29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Thu, 1 Oct 2026 10:16:56 +0200 Subject: [PATCH] fix: keep the calendar day tests independent of the current date --- tests/Controller/BookingControllerTest.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/Controller/BookingControllerTest.php b/tests/Controller/BookingControllerTest.php index d442ed0..b8df914 100644 --- a/tests/Controller/BookingControllerTest.php +++ b/tests/Controller/BookingControllerTest.php @@ -546,10 +546,13 @@ class BookingControllerTest extends WebTestCase public function testPastDaysInTheCalendarAreMarkedButStillNavigable(): void { $this->client->loginUser($this->user('anna@ep-reisen.de')); - $yesterday = (new \DateTimeImmutable('today'))->modify('-1 day')->format('Y-m-d'); + // Mid-month of last month rather than yesterday: on the 1st, yesterday is a spill-over + // day from the month before, and the out-of-month styling takes precedence over "past". + $selected = (new \DateTimeImmutable('first day of last month midnight'))->modify('+14 days'); + $past = $selected->modify('-1 day')->format('Y-m-d'); - $crawler = $this->client->request('GET', '/book/desk'); - $cell = $crawler->filter(\sprintf('button[hx-get*="/book/desk/day/%s"]', $yesterday)); + $crawler = $this->client->request('GET', '/book/desk?date='.$selected->format('Y-m-d')); + $cell = $crawler->filter(\sprintf('button[hx-get*="/book/desk/day/%s"]', $past)); self::assertCount(1, $cell); self::assertSame('true', $cell->attr('aria-disabled')); @@ -559,10 +562,13 @@ class BookingControllerTest extends WebTestCase public function testFutureDaysInTheCalendarAreNotMarkedAsPast(): void { $this->client->loginUser($this->user('anna@ep-reisen.de')); - $tomorrow = (new \DateTimeImmutable('today'))->modify('+1 day')->format('Y-m-d'); + // Mid-month of next month rather than tomorrow: on a month's last day, tomorrow falls + // outside the grid whenever that day is a Sunday. + $selected = (new \DateTimeImmutable('first day of next month midnight'))->modify('+14 days'); + $future = $selected->modify('+1 day')->format('Y-m-d'); - $crawler = $this->client->request('GET', '/book/desk'); - $cell = $crawler->filter(\sprintf('button[hx-get*="/book/desk/day/%s"]', $tomorrow)); + $crawler = $this->client->request('GET', '/book/desk?date='.$selected->format('Y-m-d')); + $cell = $crawler->filter(\sprintf('button[hx-get*="/book/desk/day/%s"]', $future)); self::assertCount(1, $cell); self::assertNull($cell->attr('aria-disabled'));