feat: enable entering additional remarks in offer confirmation

This commit is contained in:
Björn Fromme
2026-08-17 15:30:17 +02:00
parent 582e54ddc4
commit a5d97f1206
15 changed files with 387 additions and 20 deletions
@@ -294,6 +294,89 @@ class AccommodationBookingServiceTest extends TestCase
self::assertNotNull($booking->getAcceptedAt());
}
public function testAcceptBookingStoresTrimmedRemarks(): void
{
$booking = new AccommodationBooking();
$booking->setStatus(AccommodationBookingStatus::Open);
$booking->setEmail('[email protected]');
$booking->setRemarks('vom Telefonat');
$service = $this->createServiceWithAccommodation(mailer: $this->createMock(Mailer::class));
$service->acceptBooking($booking, " Bitte Zimmer im EG\nund Frühstück um 8 \n");
self::assertSame("Bitte Zimmer im EG\nund Frühstück um 8", $booking->getRemarks(), 'inner line breaks survive, outer whitespace does not');
}
public function testAcceptBookingClearsRemarksForEmptySubmission(): void
{
$booking = new AccommodationBooking();
$booking->setStatus(AccommodationBookingStatus::Open);
$booking->setEmail('[email protected]');
$booking->setRemarks('vom Telefonat');
$service = $this->createServiceWithAccommodation(mailer: $this->createMock(Mailer::class));
$service->acceptBooking($booking, ' ');
self::assertNull($booking->getRemarks(), 'an emptied textarea clears the stored remark');
}
public function testAcceptBookingLeavesRemarksUntouchedWithoutSubmission(): void
{
$booking = new AccommodationBooking();
$booking->setStatus(AccommodationBookingStatus::Open);
$booking->setEmail('[email protected]');
$booking->setRemarks('vom Telefonat');
$service = $this->createServiceWithAccommodation(mailer: $this->createMock(Mailer::class));
$service->acceptBooking($booking);
self::assertSame('vom Telefonat', $booking->getRemarks(), 'the API path must not wipe the remark');
}
public function testAcceptBookingDoesNotStoreRemarksWhenOfferIsNotOpen(): void
{
$booking = new AccommodationBooking();
$booking->setStatus(AccommodationBookingStatus::Accepted);
$booking->setRemarks('vom Telefonat');
$service = $this->createServiceWithAccommodation(mailer: $this->createMock(Mailer::class));
$service->acceptBooking($booking, 'zu spät');
self::assertSame('vom Telefonat', $booking->getRemarks());
}
public function testAcceptBookingSkipsTheCustomerEmailWhenNoAddressIsStored(): void
{
$booking = new AccommodationBooking();
$booking->setStatus(AccommodationBookingStatus::Open);
// Only the office notification goes out — the customer copy has no recipient.
$mailer = $this->createMock(Mailer::class);
$mailer
->expects(self::once())
->method('createAndSendEmail')
->with(
self::anything(),
self::callback(static fn (array $options) => '[email protected]' === $options['to']),
);
$logger = $this->createMock(LoggerInterface::class);
$logger
->expects(self::once())
->method('warning')
->with('Failed to send offer accepted customer email', self::anything());
$service = $this->createServiceWithAccommodation(mailer: $mailer, logger: $logger);
$service->acceptBooking($booking);
self::assertSame(AccommodationBookingStatus::Accepted, $booking->getStatus(), 'the acceptance itself must not fail');
}
public function testAcceptBookingIsIdempotentAndSendsNoNotifications(): void
{
$entityManager = $this->createMock(EntityManagerInterface::class);