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

use Ferienpass\CoreBundle\Entity\DbafsAttachment;
use Ferienpass\CoreBundle\Entity\Offer\Base;
use Ferienpass\CoreBundle\Entity\OfferAttachment;
use PHPUnit\Framework\TestCase;

final class OfferAttachmentTest extends TestCase
{
    public function testConstructWithOffer(): void
    {
        $offer = new Base();
        $attachment = new OfferAttachment(offer: $offer);

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

    public function testSetOffer(): void
    {
        $offer = new Base();
        $attachment = new OfferAttachment();
        $attachment->setOffer($offer);

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

    public function testIsAgreementLetterDefaultsFalse(): void
    {
        $attachment = new OfferAttachment();

        self::assertFalse($attachment->isAgreementLetter());
    }

    public function testSetAgreementLetter(): void
    {
        $attachment = new OfferAttachment();
        $attachment->setAgreementLetter(true);

        self::assertTrue($attachment->isAgreementLetter());
    }

    public function testGetSortingDefaultsToZero(): void
    {
        $attachment = new OfferAttachment();

        self::assertSame(0, $attachment->getSorting());
    }

    public function testSetSorting(): void
    {
        $attachment = new OfferAttachment();
        $attachment->setSorting(3);

        self::assertSame(3, $attachment->getSorting());
    }

    public function testConstructWithDbafsAttachment(): void
    {
        $dbafs = new DbafsAttachment();
        $attachment = new OfferAttachment(attachment: $dbafs);

        self::assertSame($dbafs, $attachment->getAttachment());
    }

    public function testSetAttachment(): void
    {
        $dbafs = new DbafsAttachment();
        $attachment = new OfferAttachment();
        $attachment->setAttachment($dbafs);

        self::assertSame($dbafs, $attachment->getAttachment());
    }
}
