<?php

declare(strict_types=1);

/*
 * This file is part of the Ferienpass package.
 *
 * (c) Richard Henkenjohann <richard@ferienpass.online>
 *
 * For more information visit the project website <https://ferienpass.online>
 * or the documentation under <https://docs.ferienpass.online>.
 */

namespace Ferienpass\CmsBundle\Tests\LiveComponent;

use Ferienpass\CmsBundle\Dto\AccessCodeDto;
use Ferienpass\CmsBundle\Dto\FriendCodeDto;
use Ferienpass\CmsBundle\LiveComponent\AccessCodeHydrationExtension;
use Ferienpass\CmsBundle\LiveComponent\FriendCodeHydrationExtension;
use Ferienpass\CoreBundle\Repository\AccessCodeStrategyRepository;
use Ferienpass\CoreBundle\Repository\OfferRepositoryInterface;
use PHPUnit\Framework\TestCase;

final class HydrationExtensionsTest extends TestCase
{
    // ---- AccessCodeHydrationExtension ----

    public function testAccessCodeSupportsAccessCodeDto(): void
    {
        $repo = $this->createMock(AccessCodeStrategyRepository::class);
        $ext = new AccessCodeHydrationExtension($repo);

        self::assertTrue($ext->supports(AccessCodeDto::class));
    }

    public function testAccessCodeDoesNotSupportOtherClasses(): void
    {
        $repo = $this->createMock(AccessCodeStrategyRepository::class);
        $ext = new AccessCodeHydrationExtension($repo);

        self::assertFalse($ext->supports(\stdClass::class));
    }

    // ---- FriendCodeHydrationExtension ----

    public function testFriendCodeSupportsFriendCodeDto(): void
    {
        $repo = $this->createMock(OfferRepositoryInterface::class);
        $ext = new FriendCodeHydrationExtension($repo);

        self::assertTrue($ext->supports(FriendCodeDto::class));
    }

    public function testFriendCodeDoesNotSupportOtherClasses(): void
    {
        $repo = $this->createMock(OfferRepositoryInterface::class);
        $ext = new FriendCodeHydrationExtension($repo);

        self::assertFalse($ext->supports(\stdClass::class));
    }
}
