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

final class DbafsAttachmentTest extends TestCase
{
    public function testConstructInitializesCollections(): void
    {
        $attachment = new DbafsAttachment();

        self::assertCount(0, $attachment->getOffers());
        self::assertCount(0, $attachment->getNotifications());
    }

    public function testGetCreatedAtIsSetOnConstruct(): void
    {
        $attachment = new DbafsAttachment();

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

    public function testGetUuidNullByDefault(): void
    {
        $attachment = new DbafsAttachment();

        self::assertNull($attachment->getUuid());
    }

    public function testGetPathNullByDefault(): void
    {
        $attachment = new DbafsAttachment();

        self::assertNull($attachment->getPath());
    }

    public function testSetCreatedAt(): void
    {
        $attachment = new DbafsAttachment();
        $dt = new \DateTimeImmutable('2024-06-15');
        $attachment->setCreatedAt($dt);

        self::assertSame($dt, $attachment->getCreatedAt());
    }

    public function testGetUploadedByNullByDefault(): void
    {
        $attachment = new DbafsAttachment();

        self::assertNull($attachment->getUploadedBy());
    }

    public function testSetUploadedBy(): void
    {
        $attachment = new DbafsAttachment();
        $user = new User();
        $attachment->setUploadedBy($user);

        self::assertSame($user, $attachment->getUploadedBy());
    }

    public function testSetLastModified(): void
    {
        $attachment = new DbafsAttachment();
        $attachment->setLastModified(1700000000);

        self::assertInstanceOf(\DateTimeInterface::class, $attachment->getLastModified());
    }

    public function testGetTitleNullByDefault(): void
    {
        $attachment = new DbafsAttachment();

        self::assertNull($attachment->getTitle());
    }

    public function testSetTitle(): void
    {
        $attachment = new DbafsAttachment();
        $attachment->setTitle('My file');

        self::assertSame('My file', $attachment->getTitle());
    }
}
