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

final class UserActivityTest extends TestCase
{
    public function testIdIsNullByDefault(): void
    {
        $user = new User();
        $activity = new UserActivity($user, null);

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

    public function testGetCreatedAtIsSetOnConstruct(): void
    {
        $user = new User();
        $activity = new UserActivity($user, null);

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

    public function testGetAccount(): void
    {
        $user = new User();
        $activity = new UserActivity($user, null);

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

    public function testIsCommentReturnsFalseWithNullComment(): void
    {
        $user = new User();
        $activity = new UserActivity($user, null, null);

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

    public function testIsCommentReturnsTrueWithComment(): void
    {
        $user = new User();
        $activity = new UserActivity($user, null, 'Some comment');

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

    public function testGetCommentReturnsNullByDefault(): void
    {
        $user = new User();
        $activity = new UserActivity($user, null);

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

    public function testGetCommentReturnsSetValue(): void
    {
        $user = new User();
        $activity = new UserActivity($user, null, 'Test comment');

        self::assertSame('Test comment', $activity->getComment());
    }

    public function testGetCreatedByNullWhenNullPassed(): void
    {
        $user = new User();
        $activity = new UserActivity($user, null);

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

    public function testGetCreatedByReturnsUser(): void
    {
        $account = new User();
        $createdBy = new User();
        $activity = new UserActivity($account, $createdBy);

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