<?php

declare(strict_types=1);

namespace App\Tests\Unit\Scolarite\Domain\Model\Competency;

use App\Scolarite\Domain\Model\Competency\CompetencyLevel;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;

final class CompetencyLevelTest extends TestCase
{
    #[Test]
    public function hasFourLevels(): void
    {
        self::assertCount(4, CompetencyLevel::cases());
    }

    #[Test]
    public function levelsHaveCorrectValues(): void
    {
        self::assertSame('not_acquired', CompetencyLevel::NOT_ACQUIRED->value);
        self::assertSame('in_progress', CompetencyLevel::IN_PROGRESS->value);
        self::assertSame('acquired', CompetencyLevel::ACQUIRED->value);
        self::assertSame('exceeded', CompetencyLevel::EXCEEDED->value);
    }

    #[Test]
    public function labelsAreInFrench(): void
    {
        self::assertSame('Non acquis', CompetencyLevel::NOT_ACQUIRED->label());
        self::assertSame('En cours d\'acquisition', CompetencyLevel::IN_PROGRESS->label());
        self::assertSame('Acquis', CompetencyLevel::ACQUIRED->label());
        self::assertSame('Dépassé', CompetencyLevel::EXCEEDED->label());
    }

    #[Test]
    public function sortOrderIsAscending(): void
    {
        self::assertSame(1, CompetencyLevel::NOT_ACQUIRED->sortOrder());
        self::assertSame(2, CompetencyLevel::IN_PROGRESS->sortOrder());
        self::assertSame(3, CompetencyLevel::ACQUIRED->sortOrder());
        self::assertSame(4, CompetencyLevel::EXCEEDED->sortOrder());
    }

    #[Test]
    public function colorsAreValid(): void
    {
        foreach (CompetencyLevel::cases() as $level) {
            self::assertMatchesRegularExpression('/^#[0-9a-f]{6}$/', $level->color());
        }
    }
}
