shopit-back/tests/Unit/Notification/SendPasswordResetEmailTest.php

30 lines
1005 B
PHP

<?php
namespace Tests\Unit\Notification;
use App\Domains\Notification\Events\PasswordResetRequested;
use App\Domains\Notification\Listeners\SendPasswordResetEmail;
use App\Domains\Notification\Services\NotificationMailService;
use RuntimeException;
use Tests\TestCase;
class SendPasswordResetEmailTest extends TestCase
{
public function test_it_delegates_mail_failures_to_the_notification_service(): void
{
$exception = new RuntimeException('SMTP unavailable.');
$mailService = \Mockery::mock(NotificationMailService::class);
$mailService->shouldReceive('sendPasswordResetCode')
->once()
->with(10, 'tenant-test', PasswordResetRequested::CHANNEL_STOREFRONT)
->andThrow($exception);
$this->app->instance(NotificationMailService::class, $mailService);
$this->expectExceptionObject($exception);
(new SendPasswordResetEmail)->handle(
new PasswordResetRequested(10, 'tenant-test'),
);
}
}