<?php

declare(strict_types=1);

namespace Seka\Portal\Modul\Statistiky\Tests\Unit\Services\Analyzators\Validators;

use Seka\Portal\Modul\Statistiky\Entities\Zaznam\Enums\StavEmisnejKontrolyEnum;
use Seka\Portal\Modul\Statistiky\Services\Analyzators\Validators\LexicalKontrolaStav;
use Seka\Portal\Modul\Statistiky\Tests\TestCase;

/**
 * Class LexicalKontrolaStavTest
 *
 * @package Seka\Portal\Modul\Statistiky\Tests\Unit\Services\Analyzators\Validators
 */
class LexicalKontrolaStavTest extends TestCase
{
    /**
     *
     */
    public function testValidateCorrectKontrolaStav()
    {
        $validator = new LexicalKontrolaStav();

        self::assertTrue($validator->validate(StavEmisnejKontrolyEnum::ARCHIV->value));
    }

    /**
     *
     */
    public function testValidateIncorrectKontrolaStav()
    {
        $validator = new LexicalKontrolaStav();

        self::assertFalse($validator->validate('INCORRECT'));
    }

    /**
     *
     */
    public function testValidateEmptyKontrolaStav()
    {
        $validator = new LexicalKontrolaStav();

        self::assertFalse($validator->validate(''));
    }

    /**
     *
     */
    public function testGetErrorMsgWithError()
    {
        $incorrectKontrolaDruh = 'INCORRECT';
        $validator = new LexicalKontrolaStav();
        $validator->validate($incorrectKontrolaDruh);
        $message = sprintf('povolene hodnoty: %s, %s', collect(StavEmisnejKontrolyEnum::cases())->map(fn($case) => $case->value)->implode(','), $incorrectKontrolaDruh);
        $actualMessage = $validator->getErrorMsg($incorrectKontrolaDruh);

        self::assertEquals($message, $actualMessage);
        self::assertIsString($actualMessage);
    }
}
