<?php

namespace Tests\Unit\Services\Attendance;

use App\Services\Attendance\LateSlipLogQueryService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;

class LateSlipLogQueryServiceTest extends TestCase
{
    use RefreshDatabase;

    public function test_paginate_filters_by_date(): void
    {
        DB::table('late_slip_logs')->insert([
            [
                'school_year' => '2025-2026',
                'semester' => 'Fall',
                'student_name' => 'Student A',
                'slip_date' => '2025-09-01',
            ],
            [
                'school_year' => '2025-2026',
                'semester' => 'Fall',
                'student_name' => 'Student B',
                'slip_date' => '2025-10-01',
            ],
        ]);

        $service = app(LateSlipLogQueryService::class);
        $pager = $service->paginate(['date_from' => '2025-10-01'], 1, 10);

        $this->assertSame(1, $pager->total());
        $this->assertSame('Student B', $pager->items()[0]->student_name);
    }
}
