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

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

        self::assertTrue($validator->validate(DruhPalivaEnum::B()->value));
        self::assertTrue($validator->validate(DruhPalivaEnum::D()->value));
        self::assertTrue($validator->validate(DruhPalivaEnum::E()->value));
        self::assertTrue($validator->validate(DruhPalivaEnum::NG()->value));
        self::assertTrue($validator->validate(DruhPalivaEnum::LPG()->value));
        self::assertTrue($validator->validate(DruhPalivaEnum::B_NG()->value));
        self::assertTrue($validator->validate(DruhPalivaEnum::B_LPG()->value));
    }

    /**
     *
     */
    public function testValidateIncorrectDruhPaliva()
    {
        $validator = new LexicalVozidloDruhPaliva();

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

    /**
     *
     */
    public function testValidateEmptyDruhPaliva()
    {
        $validator = new LexicalVozidloDruhPaliva();

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

    /**
     *
     */
    public function testGetErrorMsg()
    {
        $incorrectDruhPaliva = 'Q';
        $validator = new LexicalVozidloDruhPaliva();
        $validator->validate($incorrectDruhPaliva);
        $message = sprintf('povolene hodnoty: %s, %s', implode(',', DruhPalivaEnum::toValues()), $incorrectDruhPaliva);
        $actualMessage = $validator->getErrorMsg($incorrectDruhPaliva);

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