<?php

namespace Tests\Unit\Services\AttendanceTracking;

use App\Services\AttendanceTracking\AttendancePendingViolationService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Mockery;
use Tests\TestCase;

class AttendancePendingViolationServiceTest extends TestCase
{
    use RefreshDatabase;

    public function test_returns_error_when_no_students(): void
    {
        $resolver = Mockery::mock(\App\Services\AttendanceTracking\AttendanceViolationStudentResolverService::class);
        $resolver->shouldReceive('resolveForSchoolYear')->andReturn([
            'school_year' => '2025-2026',
            'semester' => 'Fall',
            'student_ids' => [],
            'student_codes' => [],
            'students' => [],
            'student_code_to_id' => [],
            'existing_ids' => [],
            'debug' => [],
        ]);

        $engine = Mockery::mock(\App\Services\AttendanceTracking\ViolationRuleEngineService::class);

        $service = new AttendancePendingViolationService(
            new \App\Models\AttendanceData(),
            $engine,
            $resolver
        );

        $result = $service->getPendingViolations('2025-2026', null, null);

        $this->assertSame('No student identifiers found for the current school year.', $result['error']);
    }
}
