wip: notification emails surrounding groups bookings and inquiries
This commit is contained in:
1 parent
a1751f699b
commit
d0358e584c
6 files changed
+163
-162
No files matched your search
@@ -203,15 +203,26 @@ class AccommodationBookingServiceTest extends TestCase
|
||||
self::assertNotSame($previousIssuedAt, $booking->getAccessLinkIssuedAt());
|
||||
}
|
||||
|
||||
public function testAcceptBookingTransitionsInquiryToBooking(): void
|
||||
public function testAcceptBookingTransitionsInquiryToBookingAndSendsNotifications(): void
|
||||
{
|
||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||
$entityManager->expects(self::once())->method('flush');
|
||||
|
||||
$service = $this->createServiceWithAccommodation(entityManager: $entityManager);
|
||||
|
||||
$booking = new AccommodationBooking();
|
||||
$booking->setIsInquiry(true);
|
||||
$booking->setEmail('[email protected]');
|
||||
|
||||
$mailer = $this->createMock(Mailer::class);
|
||||
$mailer
|
||||
->expects(self::exactly(2))
|
||||
->method('createAndSendEmail')
|
||||
->with(
|
||||
self::anything(),
|
||||
self::callback(static fn (array $options) => in_array($options['to'], ['[email protected]', '[email protected]'], true)
|
||||
&& in_array($options['template'], ['email/offer_accepted.html.twig', 'email/offer_accepted_customer.html.twig'], true)),
|
||||
);
|
||||
|
||||
$service = $this->createServiceWithAccommodation(entityManager: $entityManager, mailer: $mailer);
|
||||
|
||||
$service->acceptBooking($booking);
|
||||
|
||||
@@ -219,12 +230,15 @@ class AccommodationBookingServiceTest extends TestCase
|
||||
self::assertNotNull($booking->getAcceptedAt());
|
||||
}
|
||||
|
||||
public function testAcceptBookingIsIdempotent(): void
|
||||
public function testAcceptBookingIsIdempotentAndSendsNoNotifications(): void
|
||||
{
|
||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||
$entityManager->expects(self::never())->method('flush');
|
||||
|
||||
$service = $this->createServiceWithAccommodation(entityManager: $entityManager);
|
||||
$mailer = $this->createMock(Mailer::class);
|
||||
$mailer->expects(self::never())->method('createAndSendEmail');
|
||||
|
||||
$service = $this->createServiceWithAccommodation(entityManager: $entityManager, mailer: $mailer);
|
||||
|
||||
$booking = new AccommodationBooking();
|
||||
$booking->setIsInquiry(false);
|
||||
@@ -234,6 +248,39 @@ class AccommodationBookingServiceTest extends TestCase
|
||||
self::assertNull($booking->getAcceptedAt());
|
||||
}
|
||||
|
||||
public function testSendOfferAcceptedNotificationEmailLogsAndSwallowsMailerFailures(): void
|
||||
{
|
||||
$booking = new AccommodationBooking();
|
||||
$booking->setIsInquiry(false);
|
||||
|
||||
$mailer = $this->createMock(Mailer::class);
|
||||
$mailer->method('createAndSendEmail')->willThrowException(new \RuntimeException('SMTP down'));
|
||||
|
||||
$logger = $this->createMock(LoggerInterface::class);
|
||||
$logger->expects(self::once())->method('error');
|
||||
|
||||
$service = $this->createServiceWithAccommodation(mailer: $mailer, logger: $logger);
|
||||
|
||||
$service->sendOfferAcceptedNotificationEmail($booking);
|
||||
}
|
||||
|
||||
public function testSendOfferAcceptedCustomerEmailLogsAndSwallowsMailerFailures(): void
|
||||
{
|
||||
$booking = new AccommodationBooking();
|
||||
$booking->setEmail('[email protected]');
|
||||
$booking->setIsInquiry(false);
|
||||
|
||||
$mailer = $this->createMock(Mailer::class);
|
||||
$mailer->method('createAndSendEmail')->willThrowException(new \RuntimeException('SMTP down'));
|
||||
|
||||
$logger = $this->createMock(LoggerInterface::class);
|
||||
$logger->expects(self::once())->method('error');
|
||||
|
||||
$service = $this->createServiceWithAccommodation(mailer: $mailer, logger: $logger);
|
||||
|
||||
$service->sendOfferAcceptedCustomerEmail($booking);
|
||||
}
|
||||
|
||||
public function testRefreshPriceSnapshotStoresDiscountedFinalTotal(): void
|
||||
{
|
||||
$booking = new AccommodationBooking();
|
||||
|
||||
Reference in new issue
Block a user