<?php

declare(strict_types=1);

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

use App\Administration\Domain\Model\GradingConfiguration\GradingConfiguration;
use App\Administration\Domain\Model\GradingConfiguration\GradingMode;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;

final class GradingConfigurationTest extends TestCase
{
    #[Test]
    public function itCreatesNumeric20Configuration(): void
    {
        $config = new GradingConfiguration(GradingMode::NUMERIC_20);

        self::assertSame(GradingMode::NUMERIC_20, $config->mode);
    }

    #[Test]
    public function itCreatesCompetenciesConfiguration(): void
    {
        $config = new GradingConfiguration(GradingMode::COMPETENCIES);

        self::assertSame(GradingMode::COMPETENCIES, $config->mode);
    }

    #[Test]
    public function itCreatesNoGradesConfiguration(): void
    {
        $config = new GradingConfiguration(GradingMode::NO_GRADES);

        self::assertSame(GradingMode::NO_GRADES, $config->mode);
    }

    #[Test]
    public function equalConfigurationsAreEqual(): void
    {
        $config1 = new GradingConfiguration(GradingMode::NUMERIC_20);
        $config2 = new GradingConfiguration(GradingMode::NUMERIC_20);

        self::assertTrue($config1->equals($config2));
    }

    #[Test]
    public function differentConfigurationsAreNotEqual(): void
    {
        $config1 = new GradingConfiguration(GradingMode::NUMERIC_20);
        $config2 = new GradingConfiguration(GradingMode::COMPETENCIES);

        self::assertFalse($config1->equals($config2));
    }

    #[Test]
    public function itDelegatesToModeForScaleMax(): void
    {
        $config = new GradingConfiguration(GradingMode::NUMERIC_20);
        self::assertSame(20, $config->scaleMax());

        $config = new GradingConfiguration(GradingMode::COMPETENCIES);
        self::assertNull($config->scaleMax());
    }

    #[Test]
    public function itDelegatesToModeForEstNumerique(): void
    {
        self::assertTrue((new GradingConfiguration(GradingMode::NUMERIC_20))->estNumerique());
        self::assertFalse((new GradingConfiguration(GradingMode::NO_GRADES))->estNumerique());
    }

    #[Test]
    public function itDelegatesToModeForCalculeMoyenne(): void
    {
        self::assertTrue((new GradingConfiguration(GradingMode::NUMERIC_20))->calculeMoyenne());
        self::assertFalse((new GradingConfiguration(GradingMode::COMPETENCIES))->calculeMoyenne());
    }
}
