<?php

declare(strict_types=1);

namespace Ferienpass\CoreBundle\Tests\Entity;

use Ferienpass\CoreBundle\Entity\Host;
use Ferienpass\CoreBundle\Entity\HostActivity;
use Ferienpass\CoreBundle\Entity\User;
use PHPUnit\Framework\TestCase;

final class HostActivityTest extends TestCase
{
    public function testGetIdNullByDefault(): void
    {
        $activity = new HostActivity(new Host(), null);

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

    public function testGetCreatedAtIsSetOnConstruct(): void
    {
        $activity = new HostActivity(new Host(), null);

        self::assertInstanceOf(\DateTimeInterface::class, $activity->getCreatedAt());
    }

    public function testGetHost(): void
    {
        $host = new Host();
        $activity = new HostActivity($host, null);

        self::assertSame($host, $activity->getHost());
    }

    public function testIsCommentReturnsFalseWithNullComment(): void
    {
        $activity = new HostActivity(new Host(), null, null);

        self::assertFalse($activity->isComment());
    }

    public function testIsCommentReturnsTrueWithComment(): void
    {
        $activity = new HostActivity(new Host(), null, 'A comment');

        self::assertTrue($activity->isComment());
    }

    public function testGetCreatedByNullWhenNotPassed(): void
    {
        $activity = new HostActivity(new Host(), null);

        self::assertNull($activity->getCreatedBy());
    }

    public function testGetCreatedByReturnsUser(): void
    {
        $host = new Host();
        $user = new User();
        $activity = new HostActivity($host, $user);

        self::assertSame($user, $activity->getCreatedBy());
    }
}
