feat: re-generate access links for bookings when sent via email
This commit is contained in:
@@ -245,8 +245,10 @@ class AccommodationBookingServiceTest extends TestCase
|
||||
$service->sendCustomerConfirmationEmail($booking);
|
||||
}
|
||||
|
||||
public function testRegenerateAccessLinkOverwritesAccessLinkIssuedAt(): void
|
||||
public function testSendAccessLinkRefreshesTheLinkBeforeSending(): void
|
||||
{
|
||||
// The mail is the only way a link reaches the customer, so every send hands out a
|
||||
// link that is good for another full TTL — the previous one stops working.
|
||||
$booking = new AccommodationBooking();
|
||||
$booking->setEmail('[email protected]');
|
||||
$booking->setStatus(AccommodationBookingStatus::Open);
|
||||
@@ -260,7 +262,7 @@ class AccommodationBookingServiceTest extends TestCase
|
||||
$breakdownCalculator->method('compute')->willReturn(null);
|
||||
|
||||
$mailer = $this->createMock(Mailer::class);
|
||||
$mailer->expects(self::never())->method('createAndSendEmail');
|
||||
$mailer->expects(self::once())->method('createAndSendEmail');
|
||||
|
||||
$service = $this->createServiceWithAccommodation(
|
||||
entityManager: $entityManager,
|
||||
@@ -268,9 +270,28 @@ class AccommodationBookingServiceTest extends TestCase
|
||||
breakdownCalculator: $breakdownCalculator,
|
||||
);
|
||||
|
||||
$service->regenerateAccessLink($booking);
|
||||
$service->sendAccessLink($booking);
|
||||
|
||||
self::assertNotSame($previousIssuedAt, $booking->getAccessLinkIssuedAt());
|
||||
self::assertGreaterThan($previousIssuedAt, $booking->getAccessLinkIssuedAt());
|
||||
}
|
||||
|
||||
public function testSendAccessLinkNoOpsForADraft(): void
|
||||
{
|
||||
$booking = new AccommodationBooking();
|
||||
$booking->setEmail('[email protected]');
|
||||
$booking->setStatus(AccommodationBookingStatus::Draft);
|
||||
|
||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||
$entityManager->expects(self::never())->method('flush');
|
||||
|
||||
$mailer = $this->createMock(Mailer::class);
|
||||
$mailer->expects(self::never())->method('createAndSendEmail');
|
||||
|
||||
$service = $this->createServiceWithAccommodation(entityManager: $entityManager, mailer: $mailer);
|
||||
|
||||
$service->sendAccessLink($booking);
|
||||
|
||||
self::assertNull($booking->getAccessLinkIssuedAt());
|
||||
}
|
||||
|
||||
public function testADraftGetsNoAccessLinkGenerated(): void
|
||||
@@ -287,7 +308,6 @@ class AccommodationBookingServiceTest extends TestCase
|
||||
$service = $this->createServiceWithAccommodation(entityManager: $entityManager);
|
||||
|
||||
$service->issueAccessLink($booking);
|
||||
$service->regenerateAccessLink($booking);
|
||||
|
||||
self::assertNull($booking->getAccessLinkIssuedAt());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user