<?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\CoreBundle\Tests\MessageHandler;

use Ferienpass\CoreBundle\Entity\Offer\Base;
use Ferienpass\CoreBundle\Message\SyncOfferVariants as SyncOfferVariantsCommand;
use Ferienpass\CoreBundle\MessageHandler\SyncOfferVariants;
use Ferienpass\CoreBundle\Repository\OfferRepositoryInterface;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Uid\Uuid;

final class SyncOfferVariantsTest extends TestCase
{
    public function testDoesNothingWhenOfferHasNoVariants(): void
    {
        $offer = new Base();
        $offerId = Uuid::v7();
        // getVariants() returns an empty collection by default

        $offers = $this->createMock(OfferRepositoryInterface::class);
        $offers->method('findOneBy')->with(['uuid' => $offerId])->willReturn($offer);
        $offers->method('variantFields')->willReturn([]);

        $handler = new SyncOfferVariants($offers);
        $handler(new SyncOfferVariantsCommand((string) $offerId));

        $this->addToAssertionCount(1);
    }
}
