Files
alrahma_sunday_school_api/tests/Unit/Services/AttendanceTracking/AttendanceNotificationLogServiceTest.php
T
2026-06-09 01:03:53 -04:00

34 lines
1.2 KiB
PHP

<?php
namespace Tests\Unit\Services\AttendanceTracking;
use App\Services\AttendanceTracking\AttendanceNotificationLogService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
class AttendanceNotificationLogServiceTest extends TestCase
{
use RefreshDatabase;
public function test_log_notification_creates_and_updates(): void
{
$service = new AttendanceNotificationLogService(new \App\Models\ParentNotification());
$service->logNotification(1, 'ABS_1', '2025-01-01', 'email', 'parent@example.com', 'Subject', 'sent');
$this->assertDatabaseHas('parent_notifications', [
'student_id' => 1,
'code' => 'ABS_1',
'incident_date' => '2025-01-01 00:00:00',
'channel' => 'email',
'to_address' => 'parent@example.com',
'status' => 'sent',
]);
$service->logNotification(1, 'ABS_1', '2025-01-01', 'email', 'parent@example.com', 'Updated', 'failed');
$row = DB::table('parent_notifications')->where('student_id', 1)->first();
$this->assertSame('Updated', $row->subject);
$this->assertSame('failed', $row->status);
}
}