<?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\EmisnySystemEnum;
use Seka\Portal\Modul\Statistiky\Services\Analyzators\Validators\LexicalVozidloEmisnySystem;

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

        self::assertTrue($validator->validate(EmisnySystemEnum::RKAT_OBD()->value));
    }

    /**
     *
     */
    public function testValidateIncorrectEmisnySystem()
    {
        $validator = new LexicalVozidloEmisnySystem();

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

    /**
     *
     */
    public function testValidateEmptyEmisnySystem()
    {
        $validator = new LexicalVozidloEmisnySystem();

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

    /**
     *
     */
    public function testGetErrorMsgWithError()
    {
        $incorrectEmisnySystem = 'BBKKAATT';
        $validator = new LexicalVozidloEmisnySystem();
        $validator->validate($incorrectEmisnySystem);
        $message = sprintf('povolene hodnoty: %s, %s', implode(',', EmisnySystemEnum::toValues()), $incorrectEmisnySystem);
        $actualMessage = $validator->getErrorMsg($incorrectEmisnySystem);

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