<?php

declare(strict_types=1);

namespace App\Tests\Service\Rtt;

use App\Service\Rtt\SolidarityDayResolver;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

/**
 * @internal
 */
final class SolidarityDayResolverTest extends TestCase
{
    /**
     * Lundi de Pentecôte = dimanche de Pâques + 50 jours.
     * 2024 : Pâques 31/03 → 20/05 ; 2025 : Pâques 20/04 → 09/06 ; 2026 : Pâques 05/04 → 25/05.
     */
    #[DataProvider('pentecostCases')]
    public function testPentecostMonday(int $year, string $expected): void
    {
        $resolver = new SolidarityDayResolver();

        self::assertSame($expected, $resolver->pentecostMonday($year)->format('Y-m-d'));
    }

    /**
     * @return iterable<string, array{int, string}>
     */
    public static function pentecostCases(): iterable
    {
        yield '2024' => [2024, '2024-05-20'];

        yield '2025' => [2025, '2025-06-09'];

        yield '2026' => [2026, '2026-05-25'];

        // Century-boundary year: Easter 2000-04-23 → Whit Monday 2000-06-12
        // (verified with: easter_date(2000) → date('+50 days'))
        yield '2000' => [2000, '2000-06-12'];

        // Late-April Easter (2011-04-24) → Whit Monday 2011-06-13
        // (verified with: easter_date(2011) → date('+50 days'))
        yield '2011' => [2011, '2011-06-13'];

        // Easter on April 25 — exercises the computus corrective $m branch:
        // Easter 2038-04-25 → Whit Monday 2038-06-14
        // (verified with: easter_date(2038) → date('+50 days'))
        yield '2038' => [2038, '2038-06-14'];
    }

    /**
     * The returned date must always be a Monday (ISO weekday = 1).
     * Verified for 2025 as a representative case.
     */
    public function testPentecostMondayIsAMonday(): void
    {
        $resolver = new SolidarityDayResolver();

        self::assertSame('1', $resolver->pentecostMonday(2025)->format('N'));
    }
}
