<?php

declare(strict_types=1);

namespace Ferienpass\AdminBundle\Tests\Form\Type;

use Ferienpass\AdminBundle\Form\Type\MarkdownType;
use Ferienpass\AdminBundle\Form\Type\OfferImagePickerType;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\OptionsResolver\OptionsResolver;

final class FormTypeTest extends TestCase
{
    // ---- MarkdownType ----

    public function testMarkdownTypeGetParent(): void
    {
        self::assertSame(TextareaType::class, (new MarkdownType())->getParent());
    }

    public function testMarkdownTypeConfigureOptionsSetsRows(): void
    {
        $resolver = new OptionsResolver();
        $resolver->setDefined(['attr']);

        (new MarkdownType())->configureOptions($resolver);
        $resolved = $resolver->resolve([]);

        self::assertSame(10, $resolved['attr']['rows']);
    }

    // ---- OfferImagePickerType ----

    public function testOfferImagePickerTypeGetParent(): void
    {
        self::assertSame(EntityType::class, (new OfferImagePickerType())->getParent());
    }

    public function testOfferImagePickerTypeGetBlockPrefix(): void
    {
        self::assertSame('offer_image_picker', (new OfferImagePickerType())->getBlockPrefix());
    }
}
