first commit
This commit is contained in:
29
tests/Post/PostModelEdgeCasesTest.php
Normal file
29
tests/Post/PostModelEdgeCasesTest.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user