fix: prevent generating offer links while booking is in draft

This commit is contained in:
Björn Fromme
2026-08-19 13:00:43 +02:00
parent 2601e46ec4
commit 8617bf6c86
11 changed files with 442 additions and 36 deletions
@@ -69,8 +69,11 @@ class AccommodationBookingServiceTest extends TestCase
$service = $this->createServiceWithAccommodation(entityManager: $entityManager);
// Eingegangen is what persist() gives a direct booking — it is never a draft, which
// is the one status that would hold the link back.
$booking = new AccommodationBooking();
$booking->setOrigin(AccommodationBookingOrigin::Direct);
$booking->setStatus(AccommodationBookingStatus::Received);
$service->issueAccessLinkForDirectBooking($booking);
@@ -101,6 +104,7 @@ class AccommodationBookingServiceTest extends TestCase
$booking = new AccommodationBooking();
$booking->setOrigin(AccommodationBookingOrigin::Direct);
$booking->setStatus(AccommodationBookingStatus::Received);
$issuedAt = new \DateTimeImmutable('2026-01-01');
$booking->setAccessLinkIssuedAt($issuedAt);
@@ -268,6 +272,25 @@ class AccommodationBookingServiceTest extends TestCase
self::assertNotSame($previousIssuedAt, $booking->getAccessLinkIssuedAt());
}
public function testADraftGetsNoAccessLinkGenerated(): void
{
// A draft has not been offered to anyone, so there is nothing a link could show —
// the link is issued by sendOffer(), together with the mail that carries it.
$booking = new AccommodationBooking();
$booking->setEmail('[email protected]');
$booking->setStatus(AccommodationBookingStatus::Draft);
$entityManager = $this->createMock(EntityManagerInterface::class);
$entityManager->expects(self::never())->method('flush');
$service = $this->createServiceWithAccommodation(entityManager: $entityManager);
$service->issueAccessLink($booking);
$service->regenerateAccessLink($booking);
self::assertNull($booking->getAccessLinkIssuedAt());
}
public function testAnInquiryIsPersistedAsRequestedSoTheOfficeStillOwesAnOffer(): void
{
// Angefragt, not Offen: the customer has asked, nobody has offered anything yet.