Refactor Email Integration Handling

- Removed the AbstractEmailIntegrationHandler class to streamline email integration logic.
- Updated EmailIntegration class to extend AbstractIntegrationHandler instead of the removed class.
- Modified FormEmailNotification to handle mailer configuration internally, eliminating the need to pass the mailer as a parameter.

These changes enhance the clarity and maintainability of the email integration process by consolidating configuration logic and reducing class dependencies.
This commit is contained in:
Julien Nahum
2025-01-14 11:53:31 +01:00
parent 06c35121a0
commit e3fd709326
4 changed files with 37 additions and 61 deletions

View File

@@ -3,6 +3,7 @@
use App\Notifications\Forms\FormEmailNotification;
use Tests\Helpers\FormSubmissionDataFactory;
use Illuminate\Notifications\AnonymousNotifiable;
use Illuminate\Support\Facades\Notification;
it('can not save custom SMTP settings if not pro user', function () {
$user = $this->actingAsUser();
@@ -54,8 +55,12 @@ it('send email with custom SMTP settings', function () {
new AnonymousNotifiable(),
FormEmailNotification::class,
function (FormEmailNotification $notification, $channels, $notifiable) {
$renderedMail = $notification->toMail($notifiable);
return $notifiable->routes['mail'] === 'test@test.com' &&
$notification->mailer === 'custom_smtp';
config('mail.mailers.custom_smtp.host') === 'custom.smtp.host' &&
config('mail.mailers.custom_smtp.port') === '587' &&
config('mail.mailers.custom_smtp.username') === 'custom_username' &&
config('mail.mailers.custom_smtp.password') === 'custom_password';
}
);
});