<?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\Dto;

use Ferienpass\CmsBundle\Dto\FriendCodeDto;
use Ferienpass\CoreBundle\Entity\Offer\OfferInterface;
use PHPUnit\Framework\TestCase;

final class FriendCodeDtoTest extends TestCase
{
    public function testGetOfferReturnsOffer(): void
    {
        $offer = $this->createStub(OfferInterface::class);
        $dto = new FriendCodeDto($offer);

        self::assertSame($offer, $dto->getOffer());
    }

    public function testGetCodeIsNullByDefault(): void
    {
        $offer = $this->createStub(OfferInterface::class);
        $dto = new FriendCodeDto($offer);

        self::assertNull($dto->getCode());
    }

    public function testSetCodeAndGetCode(): void
    {
        $offer = $this->createStub(OfferInterface::class);
        $dto = new FriendCodeDto($offer, 'FRIEND-CODE-123');

        self::assertSame('FRIEND-CODE-123', $dto->getCode());
    }

    public function testSetCodeUpdatesCode(): void
    {
        $offer = $this->createStub(OfferInterface::class);
        $dto = new FriendCodeDto($offer);
        $dto->setCode('NEW-CODE');

        self::assertSame('NEW-CODE', $dto->getCode());
    }
}
