feat(mail): implement MailService for tenant-specific SMTP configuration and update MailTestService to utilize it
This commit is contained in:
@@ -4,6 +4,8 @@ namespace Tests\Feature\MailTest;
|
||||
|
||||
use App\Domains\Attachable\Enums\AttachmentType;
|
||||
use App\Domains\Attachable\Models\Attachment;
|
||||
use App\Domains\Integration\Models\Integration;
|
||||
use App\Domains\Integration\Models\TenantIntegration;
|
||||
use App\Domains\MailTest\Mailables\TestMail;
|
||||
use App\Domains\Tenant\Models\Tenant;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
@@ -55,6 +57,36 @@ class MailTestControllerTest extends TestCase
|
||||
});
|
||||
}
|
||||
|
||||
public function test_it_uses_the_tenant_email_integration_when_configured(): void
|
||||
{
|
||||
Mail::fake();
|
||||
$tenant = $this->createTenant();
|
||||
|
||||
Integration::create([
|
||||
'integration_code' => 'email',
|
||||
'name' => 'Email',
|
||||
]);
|
||||
TenantIntegration::create([
|
||||
'tenant_code' => $tenant->codigo,
|
||||
'integration_code' => 'email',
|
||||
'integration_data' => [
|
||||
'MAIL_SCHEME' => 'smtp',
|
||||
'MAIL_HOST' => 'smtp.example.com',
|
||||
'MAIL_PORT' => 587,
|
||||
'MAIL_USERNAME' => 'mailer@example.com',
|
||||
'MAIL_PASSWORD' => 'secret',
|
||||
'MAIL_FROM_ADDRESS' => 'store@example.com',
|
||||
],
|
||||
]);
|
||||
|
||||
$this->postJson('/api/acme/mail-test/send', [
|
||||
'to' => 'recipient@example.com',
|
||||
])->assertOk()
|
||||
->assertJsonPath('mailer', 'tenant-smtp');
|
||||
|
||||
Mail::assertSent(TestMail::class);
|
||||
}
|
||||
|
||||
public function test_it_validates_the_recipient(): void
|
||||
{
|
||||
Mail::fake();
|
||||
|
||||
Reference in New Issue
Block a user