<?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\BlockedContact;
use Ferienpass\CoreBundle\Entity\User;
use PHPUnit\Framework\TestCase;

final class BlockedContactTest extends TestCase
{
    public function testGetEmailReturnsEmail(): void
    {
        $contact = new BlockedContact('test@example.com');

        self::assertSame('test@example.com', $contact->getEmail());
    }

    public function testGetUserReturnsNullByDefault(): void
    {
        $contact = new BlockedContact('test@example.com');

        self::assertNull($contact->getUser());
    }

    public function testGetUserReturnsUser(): void
    {
        $user = new User();
        $contact = new BlockedContact('test@example.com', $user);

        self::assertSame($user, $contact->getUser());
    }

    public function testGetIdIsNullByDefault(): void
    {
        $contact = new BlockedContact('test@example.com');

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

    public function testGetCreatedAtIsSetOnConstruct(): void
    {
        $before = new \DateTimeImmutable();
        $contact = new BlockedContact('test@example.com');
        $after = new \DateTimeImmutable();

        self::assertGreaterThanOrEqual($before, $contact->getCreatedAt());
        self::assertLessThanOrEqual($after, $contact->getCreatedAt());
    }
}
