<?php

declare(strict_types=1);

namespace Seka\Portal\Modul\Statistiky\Tests\Unit\Services\Transformators;

use Seka\Portal\Modul\Statistiky\Tests\TestCase;
use Seka\Portal\Modul\Statistiky\Services\Import\File;
use Seka\Portal\Modul\Statistiky\Entities\Zaznam\DTOs\ImportLineDTO;
use Seka\Portal\Modul\Statistiky\Services\Transformators\CSVDataTransformator;

/**
 * Class CSVDataTransformatorTest
 *
 * @package Seka\Portal\Modul\Statistiky\Tests\Unit\Services\Transformators
 */
class CSVDataTransformatorTest extends TestCase
{
    /**
     * @var \Seka\Portal\Modul\Statistiky\Services\Transformators\CSVDataTransformator
     */
    private CSVDataTransformator $transformator;

    /**
     * @var \Seka\Portal\Modul\Statistiky\Services\Import\File
     */
    private File $file;

    /**
     *
     */
    public function setUp(): void
    {
        parent::setUp();

        $this->transformator = new CSVDataTransformator();
        $this->file = new File(__DIR__ . '/../DENNY_VYPIS_KONTROL.csv');
    }

    /**
     *
     */
    public function testInstance()
    {
        self::assertInstanceOf(CSVDataTransformator::class, $this->transformator);
    }

    /**
     *
     */
    public function testTransform()
    {
        $result = $this->transformator->transform($this->file);

        self::assertIsArray($result);
        self::assertCount(6339, $result);

        foreach ($result as $item) {
            self::assertInstanceOf(ImportLineDTO::class, $item);
        }
    }
}
