<?php

declare(strict_types=1);

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

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

/**
 * 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', implode(',', StavEmisnejKontrolyEnum::toValues()), $incorrectKontrolaDruh);
        $actualMessage = $validator->getErrorMsg($incorrectKontrolaDruh);

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