fix: consolidate purchase confirmation emails

This commit is contained in:
2026-08-26 11:29:53 -03:00
parent d0424c5589
commit dc33e5dc09
14 changed files with 69 additions and 206 deletions

View File

@@ -42,31 +42,11 @@ class NotificationMailServiceLoggingTest extends TestCase
'purchase_id' => 123,
'reason' => 'purchase_not_found',
'missing_model' => Purchase::class,
'email_type' => 'purchase_paid',
'email_type' => 'purchase_confirmed',
],
);
$this->service->sendPurchasePaid(123);
}
public function test_missing_purchase_log_includes_the_requested_ticket_ids(): void
{
$this->createEmptyPurchasesTable();
Log::shouldReceive('channel')->once()->with('emails')->andReturnSelf();
Log::shouldReceive('warning')->once()->with(
'Notification email skipped.',
[
'purchase_id' => 123,
'requested_ticket_count' => 2,
'requested_ticket_ids' => [10, 11],
'reason' => 'purchase_not_found',
'missing_model' => Purchase::class,
'email_type' => 'tickets_available',
],
);
$this->service->sendTicketsAvailable(123, [10, 11]);
$this->service->sendPurchaseConfirmed(123);
}
public function test_it_logs_successful_delivery_with_the_mailer(): void
@@ -97,13 +77,13 @@ class NotificationMailServiceLoggingTest extends TestCase
Log::shouldReceive('error')->once()->with(
'Notification email delivery failed.',
Mockery::on(fn (array $context): bool => $context['purchase_id'] === 123
&& $context['email_type'] === 'purchase_paid'
&& $context['email_type'] === 'purchase_confirmed'
&& $context['exception'] === $exception),
);
$this->expectExceptionObject($exception);
$this->sendLogged('purchase_paid', ['purchase_id' => 123], function () use ($exception): array {
$this->sendLogged('purchase_confirmed', ['purchase_id' => 123], function () use ($exception): array {
throw $exception;
});
}