<?php

declare(strict_types=1);

namespace App\Tests\Unit\Service;

use App\Module\Absence\Domain\Service\PublicHolidayProvider;
use DateTimeImmutable;
use PHPUnit\Framework\TestCase;

/**
 * @internal
 */
class PublicHolidayProviderTest extends TestCase
{
    private PublicHolidayProvider $provider;

    protected function setUp(): void
    {
        $this->provider = new PublicHolidayProvider();
    }

    public function testReturnsElevenHolidaysForMetropole(): void
    {
        self::assertCount(11, $this->provider->getHolidays(2026));
    }

    public function testFixedHolidaysHaveCorrectLabels(): void
    {
        $holidays = $this->provider->getHolidays(2026);

        self::assertSame('Jour de l\'an', $holidays['2026-01-01']);
        self::assertSame('Fête du Travail', $holidays['2026-05-01']);
        self::assertSame('Victoire 1945', $holidays['2026-05-08']);
        self::assertSame('Fête nationale', $holidays['2026-07-14']);
        self::assertSame('Assomption', $holidays['2026-08-15']);
        self::assertSame('Toussaint', $holidays['2026-11-01']);
        self::assertSame('Armistice 1918', $holidays['2026-11-11']);
        self::assertSame('Noël', $holidays['2026-12-25']);
    }

    /**
     * Easter 2026 is April 5th, so Easter Monday is April 6th,
     * Ascension is May 14th and Whit Monday is May 25th.
     */
    public function testEasterBasedHolidays2026(): void
    {
        $holidays = $this->provider->getHolidays(2026);

        self::assertSame('Lundi de Pâques', $holidays['2026-04-06']);
        self::assertSame('Ascension', $holidays['2026-05-14']);
        self::assertSame('Lundi de Pentecôte', $holidays['2026-05-25']);
    }

    /**
     * Easter 2025 is April 20th, so Easter Monday is April 21st.
     */
    public function testEasterBasedHolidays2025(): void
    {
        $holidays = $this->provider->getHolidays(2025);

        self::assertSame('Lundi de Pâques', $holidays['2025-04-21']);
    }

    public function testIsHoliday(): void
    {
        self::assertTrue($this->provider->isHoliday(new DateTimeImmutable('2026-05-01')));
        self::assertTrue($this->provider->isHoliday(new DateTimeImmutable('2026-05-14')));
        self::assertFalse($this->provider->isHoliday(new DateTimeImmutable('2026-05-02')));
        self::assertFalse($this->provider->isHoliday(new DateTimeImmutable('2026-06-01')));
    }
}
