Teren-app/tests/Unit/EmailLogTest.php

29 lines
800 B
PHP

<?php
use App\Models\EmailLog;
use App\Models\EmailLogStatus;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Str;
uses(RefreshDatabase::class);
it('persists to_recipients array when filling and saving', function () {
$log = new EmailLog();
$log->fill([
'uuid' => (string) Str::uuid(),
'to_email' => 'first@example.com',
'to_recipients' => ['first@example.com', 'second@example.com'],
'subject' => 'Test Subject',
'status' => EmailLogStatus::Queued,
'queued_at' => now(),
]);
$log->save();
$fresh = EmailLog::query()->findOrFail($log->id);
expect($fresh->to_recipients)
->toBeArray()
->and($fresh->to_recipients)
->toContain('first@example.com', 'second@example.com');
});