feat: add two- and four-weekly series and drop the weekday picker

This commit is contained in:
fromme committed 2026-09-14 08:25:05 +02:00
1 parent 8b88384d68
commit faef4d70a8
10 files changed
+166 -103

No files matched your search

+28 -23
View File
@@ -322,18 +322,37 @@ class BookingControllerTest extends WebTestCase
$this->client->loginUser($this->user('[email protected]'));
$desk = $this->resource('D1');
// 2026-10-05 is a Monday.
// 2026-10-05 is a Monday, and the weekday is taken from it rather than asked for --
// the Mondays up to the 30th are the 5th, 12th, 19th and 26th.
$response = $this->submitBookingModal($desk, '2026-10-05', [
'startTime' => '09:00',
'endTime' => '12:00',
'repeat' => 'weekly',
'weekdays' => ['1', '4'],
'until' => '2026-10-30',
]);
self::assertSame(Response::HTTP_OK, $response->getStatusCode());
self::assertCount(8, $this->em->getRepository(Booking::class)->findBy(['resource' => $desk]));
self::assertStringContainsString('8 Termine gebucht', (string) $response->getContent());
$occurrences = $this->em->getRepository(Booking::class)->findBy(['resource' => $desk]);
self::assertCount(4, $occurrences);
self::assertStringContainsString('4 Termine gebucht', (string) $response->getContent());
foreach ($occurrences as $booking) {
self::assertSame(1, (int) $booking->getDate()->format('N'));
}
}
public function testAFourWeeklySeriesIsCreatedAndReported(): void
{
$this->client->loginUser($this->user('[email protected]'));
$desk = $this->resource('D1');
$response = $this->submitBookingModal($desk, '2026-10-05', [
'allDay' => '1',
'repeat' => 'four_weekly',
'until' => '2026-12-31',
]);
self::assertSame(Response::HTTP_OK, $response->getStatusCode());
self::assertCount(4, $this->em->getRepository(Booking::class)->findBy(['resource' => $desk]));
}
public function testASeriesWithoutAnEndDateIsRejected(): void
@@ -349,20 +368,6 @@ class BookingControllerTest extends WebTestCase
self::assertStringContainsString('Bitte ein Enddatum für die Serie angeben.', (string) $response->getContent());
}
public function testAWeeklySeriesWithoutWeekdaysIsRejected(): void
{
$this->client->loginUser($this->user('[email protected]'));
$response = $this->submitBookingModal($this->resource('D1'), '2026-10-05', [
'allDay' => '1',
'repeat' => 'weekly',
'until' => '2026-10-30',
]);
self::assertSame(Response::HTTP_UNPROCESSABLE_ENTITY, $response->getStatusCode());
self::assertStringContainsString('Bitte mindestens einen Wochentag wählen.', (string) $response->getContent());
}
public function testASeriesRunningTooFarOutIsRejected(): void
{
$this->client->loginUser($this->user('[email protected]'));
@@ -417,7 +422,6 @@ class BookingControllerTest extends WebTestCase
'startTime' => '09:00',
'endTime' => '12:00',
'repeat' => 'weekly',
'weekdays' => ['1'],
'until' => '2026-10-26',
]);
@@ -451,10 +455,11 @@ class BookingControllerTest extends WebTestCase
/**
* Renders the modal, reads its CSRF token, and posts the given booking fields back to it.
*
* Posted explicitly rather than through DomCrawler's form(): the weekday checkboxes are an
* expanded multiple choice rendered as booking[weekdays][], which the crawler's field
* registry indexes positionally, so assigning ['1', '4'] sets the second checkbox instead of
* the fourth. The token still comes off the rendered form, so the round trip is real.
* Posted explicitly rather than through DomCrawler's form(), which lets a test name only the
* fields it cares about and leave the rest at their rendered defaults. The token still comes
* off the rendered form, so the round trip is real. (This originally worked around the
* weekday checkboxes, which the crawler indexed positionally; they are gone, but posting
* directly is still the simpler way to drive the modal.)
*
* @param array<string, mixed> $fields
*/