<?php

namespace Tests\Unit\Services\Attendance;

use App\Models\LateSlipLog;
use App\Services\Attendance\LateSlipLogCommandService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class LateSlipLogCommandServiceTest extends TestCase
{
    use RefreshDatabase;

    public function test_delete_removes_log(): void
    {
        $log = LateSlipLog::query()->create([
            'school_year' => '2025-2026',
            'semester' => 'Fall',
            'student_name' => 'Student X',
            'slip_date' => '2025-09-01',
            'time_in' => '08:05:00',
            'grade' => '4',
            'reason' => 'Traffic',
            'admin_name' => 'Admin User',
        ]);

        $service = app(LateSlipLogCommandService::class);
        $deleted = $service->delete($log);

        $this->assertTrue($deleted);
        $this->assertDatabaseMissing('late_slip_logs', ['id' => $log->id]);
    }
}
