<?php

declare(strict_types=1);

namespace KupShop\ContentBundle\Tests;

use KupShop\ContentBundle\Entity\Slider;
use KupShop\ContentBundle\Util\SliderUtil;

class SliderTest extends \DatabaseTestCase
{
    private SliderUtil $sliderUtil;

    protected function setUp(): void
    {
        parent::setUp();

        $this->sliderUtil = $this->get(SliderUtil::class);
    }

    public function testGetSliderById(): void
    {
        $slider = $this->sliderUtil->get(1);

        $this->assertSliderIsValid($slider);
    }

    public function testGetSliderByName(): void
    {
        $slider = $this->sliderUtil->getByName('Úvod');

        $this->assertSliderIsValid($slider);
    }

    public function testGetSliderRandom(): void
    {
        $slider = $this->sliderUtil->get(1, true);

        $this->assertSliderIsValid($slider);
        $this->assertCount(1, $slider->images, 'Banner by mel mit jen jeden nahodny slide, protoze random = true');
    }

    private function assertSliderIsValid(Slider $slider): void
    {
        $this->assertEquals(1, $slider->id);
        $this->assertNotEmpty($slider->images);
    }
}
