<?php

namespace Tests\Unit\Services\AttendanceTracking;

use App\Services\AttendanceTracking\AttendanceViolationStudentResolverService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;

class AttendanceViolationStudentResolverServiceTest extends TestCase
{
    use RefreshDatabase;

    public function test_resolve_for_school_year_returns_students(): void
    {
        DB::table('students')->insert([
            'id' => 1,
            'school_id' => 'S1',
            'firstname' => 'Student',
            'lastname' => 'One',
            'age' => 8,
            'gender' => 'Male',
            'photo_consent' => 1,
            'parent_id' => 1,
            'year_of_registration' => '2025',
            'school_year' => '2025-2026',
        ]);

        DB::table('student_class')->insert([
            'student_id' => 1,
            'class_section_id' => 10,
            'semester' => 'Fall',
            'school_year' => '2025-2026',
        ]);

        $service = new AttendanceViolationStudentResolverService(
            new \App\Models\Student(),
            new \App\Models\StudentClass(),
            new \App\Models\AttendanceData()
        );

        $result = $service->resolveForSchoolYear('2025-2026', 'Fall');

        $this->assertContains(1, $result['student_ids']);
        $this->assertNotEmpty($result['students']);
    }
}
