30 lines
868 B
PHP
30 lines
868 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Post;
|
|
|
|
use App\Post\Post;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class PostModelEdgeCasesTest extends TestCase
|
|
{
|
|
public function testFromArrayKeepsMissingOptionalFieldsNull(): void
|
|
{
|
|
$post = Post::fromArray([
|
|
'id' => 3,
|
|
'title' => 'Titre',
|
|
'content' => '<p>Texte</p>',
|
|
'slug' => 'titre',
|
|
]);
|
|
|
|
self::assertSame(3, $post->getId());
|
|
self::assertNull($post->getAuthorId());
|
|
self::assertNull($post->getAuthorUsername());
|
|
self::assertNull($post->getCategoryId());
|
|
self::assertNull($post->getCategoryName());
|
|
self::assertNull($post->getCategorySlug());
|
|
self::assertInstanceOf(\DateTime::class, $post->getCreatedAt());
|
|
self::assertInstanceOf(\DateTime::class, $post->getUpdatedAt());
|
|
}
|
|
}
|