feat(notification): enhance email logging and refactor event handling to use scalar identifiers

This commit is contained in:
2026-08-26 09:38:19 -03:00
parent 28d09dedab
commit d0424c5589
13 changed files with 381 additions and 176 deletions

View File

@@ -5,13 +5,12 @@ namespace Tests\Unit\Notification;
use App\Domains\Notification\Events\PasswordResetRequested;
use App\Domains\Notification\Listeners\SendPasswordResetEmail;
use App\Domains\Notification\Services\NotificationMailService;
use Illuminate\Support\Facades\Log;
use RuntimeException;
use Tests\TestCase;
class SendPasswordResetEmailTest extends TestCase
{
public function test_it_logs_and_rethrows_mail_failures(): void
public function test_it_delegates_mail_failures_to_the_notification_service(): void
{
$exception = new RuntimeException('SMTP unavailable.');
$mailService = \Mockery::mock(NotificationMailService::class);
@@ -21,16 +20,6 @@ class SendPasswordResetEmailTest extends TestCase
->andThrow($exception);
$this->app->instance(NotificationMailService::class, $mailService);
Log::shouldReceive('error')
->once()
->with(
'Failed to send password reset email.',
\Mockery::on(fn (array $context): bool => $context['attempt_id'] === 10
&& $context['tenant_code'] === 'tenant-test'
&& $context['channel'] === PasswordResetRequested::CHANNEL_STOREFRONT
&& $context['exception'] === $exception),
);
$this->expectExceptionObject($exception);
(new SendPasswordResetEmail)->handle(