<?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\Participant\BaseParticipant;
use Ferienpass\CoreBundle\Entity\ParticipantDuplicate;
use PHPUnit\Framework\TestCase;

final class ParticipantDuplicateTest extends TestCase
{
    public function testConstructSetsFields(): void
    {
        $participant = new BaseParticipant();
        $duplicate = new BaseParticipant();

        $record = new ParticipantDuplicate($participant, $duplicate, ParticipantDuplicate::TYPE_TOLERATED);

        self::assertSame($participant, $record->getParticipant());
        self::assertSame($duplicate, $record->getDuplicate());
        self::assertSame(ParticipantDuplicate::TYPE_TOLERATED, $record->getType());
    }

    public function testGetIdNullByDefault(): void
    {
        $participant = new BaseParticipant();
        $duplicate = new BaseParticipant();

        $record = new ParticipantDuplicate($participant, $duplicate, ParticipantDuplicate::TYPE_IGNORED);

        self::assertNull($record->getId());
    }

    public function testSetType(): void
    {
        $participant = new BaseParticipant();
        $duplicate = new BaseParticipant();

        $record = new ParticipantDuplicate($participant, $duplicate, ParticipantDuplicate::TYPE_TOLERATED);
        $record->setType(ParticipantDuplicate::TYPE_IGNORED);

        self::assertSame(ParticipantDuplicate::TYPE_IGNORED, $record->getType());
    }
}
