<?php

declare(strict_types=1);

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

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

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

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

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

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

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

    /**
     *
     * @throws \PhpOffice\PhpSpreadsheet\Exception
     */
    public function testTransform()
    {
        $result = $this->transformator->transform($this->file);

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

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