<?php

namespace Tests\Unit\Services\AttendanceTracking;

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

class ViolationRuleEngineServiceTest extends TestCase
{
    use RefreshDatabase;

    public function test_school_year_helpers(): void
    {
        $service = $this->makeService();

        $this->assertSame(['2025-08-01', '2026-07-31'], $service->deriveSchoolYearBounds('2025-2026'));
        $this->assertSame('2025-2026', $service->schoolYearForDate('2025-09-01'));
    }

    public function test_window_weeks_for_violation_code(): void
    {
        $service = $this->makeService();

        $this->assertSame(3, $service->windowWeeksForViolationCode('ABS_2'));
        $this->assertSame(4, $service->windowWeeksForViolationCode('MIX'));
        $this->assertSame(5, $service->windowWeeksForViolationCode('ABS_4'));
    }

    private function makeService(): ViolationRuleEngineService
    {
        $tracking = new \App\Models\AttendanceTracking();
        $parentLookup = Mockery::mock(\App\Services\AttendanceTracking\AttendanceParentLookupService::class);

        return new ViolationRuleEngineService($tracking, $parentLookup);
    }
}
