<?php

declare(strict_types=1);

namespace Ferienpass\AdminBundle\Tests\Form\Offer;

use Ferienpass\AdminBundle\Form\Offer\ApplicationDeadline;
use Ferienpass\AdminBundle\Form\Offer\ApplyText;
use Ferienpass\AdminBundle\Form\Offer\Attachments;
use Ferienpass\AdminBundle\Form\Offer\Categories;
use Ferienpass\AdminBundle\Form\Offer\Contact;
use Ferienpass\AdminBundle\Form\Offer\Description;
use Ferienpass\AdminBundle\Form\Offer\DisableOnlinePayment;
use Ferienpass\AdminBundle\Form\Offer\Edition;
use Ferienpass\AdminBundle\Form\Offer\Fee;
use Ferienpass\AdminBundle\Form\Offer\Hosts;
use Ferienpass\AdminBundle\Form\Offer\MaxAge;
use Ferienpass\AdminBundle\Form\Offer\MaxParticipants;
use Ferienpass\AdminBundle\Form\Offer\MinAge;
use Ferienpass\AdminBundle\Form\Offer\MinParticipants;
use Ferienpass\AdminBundle\Form\Offer\Name;
use Ferienpass\AdminBundle\Form\Offer\OnlineApplication;
use Ferienpass\AdminBundle\Form\Offer\RequiresApplication;
use Ferienpass\AdminBundle\Form\Offer\UploadMedia;
use Ferienpass\AdminBundle\Form\Offer\WheelchairAccessible;
use Ferienpass\AdminBundle\Form\Type\MarkdownType;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Contracts\Translation\TranslatorInterface;
use Symfony\UX\Dropzone\Form\DropzoneType;
use Symfony\UX\LiveComponent\Form\Type\LiveCollectionType;

final class OfferFormTypesTest extends TestCase
{
    public function testNameGetParent(): void
    {
        self::assertSame(TextType::class, (new Name())->getParent());
    }

    public function testNameConfigureOptionsRequiresRequired(): void
    {
        $resolver = new OptionsResolver();
        $resolver->setDefined('required');

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

        self::assertTrue($resolved['required']);
    }

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

    public function testFeeGetParent(): void
    {
        self::assertSame(MoneyType::class, (new Fee())->getParent());
    }

    public function testMaxAgeGetParent(): void
    {
        self::assertSame(IntegerType::class, (new MaxAge())->getParent());
    }

    public function testMinAgeGetParent(): void
    {
        self::assertSame(IntegerType::class, (new MinAge())->getParent());
    }

    public function testMaxParticipantsGetParent(): void
    {
        self::assertSame(IntegerType::class, (new MaxParticipants())->getParent());
    }

    public function testMinParticipantsGetParent(): void
    {
        self::assertSame(IntegerType::class, (new MinParticipants())->getParent());
    }

    public function testWheelchairAccessibleGetParent(): void
    {
        self::assertSame(ChoiceType::class, (new WheelchairAccessible())->getParent());
    }

    public function testOnlineApplicationGetParent(): void
    {
        self::assertSame(CheckboxType::class, (new OnlineApplication())->getParent());
    }

    public function testRequiresApplicationGetParent(): void
    {
        self::assertSame(CheckboxType::class, (new RequiresApplication())->getParent());
    }

    public function testDisableOnlinePaymentGetParent(): void
    {
        self::assertSame(CheckboxType::class, (new DisableOnlinePayment())->getParent());
    }

    public function testApplicationDeadlineGetParent(): void
    {
        $pageConfigManager = $this->createMock(\Ferienpass\CoreBundle\Settings\PageConfigManager::class);
        self::assertSame(DateTimeType::class, (new ApplicationDeadline($pageConfigManager))->getParent());
    }

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

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

    public function testEditionGetParent(): void
    {
        $translator = $this->createMock(TranslatorInterface::class);
        self::assertSame(EntityType::class, (new Edition($translator))->getParent());
    }

    public function testHostsGetParent(): void
    {
        $security = $this->createMock(Security::class);
        self::assertSame(EntityType::class, (new Hosts($security))->getParent());
    }

    public function testAttachmentsGetParent(): void
    {
        self::assertSame(LiveCollectionType::class, (new Attachments())->getParent());
    }

    public function testUploadMediaGetParent(): void
    {
        self::assertSame(DropzoneType::class, (new UploadMedia())->getParent());
    }

    public function testContactGetParent(): void
    {
        $requestStack = $this->createMock(RequestStack::class);
        self::assertSame(LiveCollectionType::class, (new Contact($requestStack))->getParent());
    }
}
