<?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\Services\Analyzators\Validators\LexicalKontrolaDatum;

/**
 * Class LexicalKontrolaDatumTest
 *
 * @package Seka\Portal\Modul\Statistiky\Tests\Unit\Services\Analyzators\Validators
 */
class LexicalKontrolaDatumTest extends TestCase
{
    /**
     * @var string
     */
    private string $dateWithCorrectDateFormat = '23.05.2021';

    /**
     * @var string
     */
    private string $dateWithIncorrectDateFormat = '2021-05-21';

    /**
     *
     */
    public function testValidateTrue()
    {
        $validator = new LexicalKontrolaDatum();

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

    /**
     *
     */
    public function testValidateFalse()
    {
        $validator = new LexicalKontrolaDatum();

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

    /**
     *
     */
    public function testGetErrorMsgWithError()
    {
        $validator = new LexicalKontrolaDatum();
        $validator->validate($this->dateWithIncorrectDateFormat);
        $message = sprintf('povoleny format: d.m.Y, %s', $this->dateWithIncorrectDateFormat);
        $actualMessage = $validator->getErrorMsg($this->dateWithIncorrectDateFormat);

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