<?php

declare(strict_types=1);

namespace App\Tests\Unit\Administration\Domain\Model\SchoolClass;

use App\Administration\Domain\Model\SchoolClass\SchoolLevel;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;

final class SchoolLevelTest extends TestCase
{
    #[Test]
    #[DataProvider('primaryLevelsProvider')]
    public function estPrimaireReturnsTrueForPrimaryLevels(SchoolLevel $level): void
    {
        self::assertTrue($level->estPrimaire());
        self::assertFalse($level->estCollege());
        self::assertFalse($level->estLycee());
        self::assertSame('Primaire', $level->cycle());
    }

    /**
     * @return array<string, array{SchoolLevel}>
     */
    public static function primaryLevelsProvider(): array
    {
        return [
            'CP' => [SchoolLevel::CP],
            'CE1' => [SchoolLevel::CE1],
            'CE2' => [SchoolLevel::CE2],
            'CM1' => [SchoolLevel::CM1],
            'CM2' => [SchoolLevel::CM2],
        ];
    }

    #[Test]
    #[DataProvider('collegeLevelsProvider')]
    public function estCollegeReturnsTrueForCollegeLevels(SchoolLevel $level): void
    {
        self::assertFalse($level->estPrimaire());
        self::assertTrue($level->estCollege());
        self::assertFalse($level->estLycee());
        self::assertSame('Collège', $level->cycle());
    }

    /**
     * @return array<string, array{SchoolLevel}>
     */
    public static function collegeLevelsProvider(): array
    {
        return [
            '6ème' => [SchoolLevel::SIXIEME],
            '5ème' => [SchoolLevel::CINQUIEME],
            '4ème' => [SchoolLevel::QUATRIEME],
            '3ème' => [SchoolLevel::TROISIEME],
        ];
    }

    #[Test]
    #[DataProvider('lyceeLevelsProvider')]
    public function estLyceeReturnsTrueForLyceeLevels(SchoolLevel $level): void
    {
        self::assertFalse($level->estPrimaire());
        self::assertFalse($level->estCollege());
        self::assertTrue($level->estLycee());
        self::assertSame('Lycée', $level->cycle());
    }

    /**
     * @return array<string, array{SchoolLevel}>
     */
    public static function lyceeLevelsProvider(): array
    {
        return [
            '2nde' => [SchoolLevel::SECONDE],
            '1ère' => [SchoolLevel::PREMIERE],
            'Terminale' => [SchoolLevel::TERMINALE],
        ];
    }

    #[Test]
    public function labelReturnsValue(): void
    {
        self::assertSame('6ème', SchoolLevel::SIXIEME->label());
        self::assertSame('CM2', SchoolLevel::CM2->label());
        self::assertSame('Terminale', SchoolLevel::TERMINALE->label());
    }

    #[Test]
    public function valueMatchesExpectedString(): void
    {
        self::assertSame('CP', SchoolLevel::CP->value);
        self::assertSame('6ème', SchoolLevel::SIXIEME->value);
        self::assertSame('2nde', SchoolLevel::SECONDE->value);
    }
}
