test Post entity feature slot
This commit is contained in:
parent
ec4f729c63
commit
64a334c63e
1 changed files with 50 additions and 0 deletions
50
backend/tests/Unit/Post/PostTest.php
Normal file
50
backend/tests/Unit/Post/PostTest.php
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Unit\Post;
|
||||
|
||||
use App\Post\Post;
|
||||
use DateTimeImmutable;
|
||||
use DateTimeZone;
|
||||
use Tests\TestCase;
|
||||
|
||||
class PostTest extends TestCase
|
||||
{
|
||||
public function test_post_exposes_all_properties(): void
|
||||
{
|
||||
$createdAt = new DateTimeImmutable(
|
||||
'2026-05-06T12:00:00',
|
||||
new DateTimeZone('UTC'),
|
||||
);
|
||||
$post = new Post(
|
||||
id: 7,
|
||||
userId: 3,
|
||||
title: 'Hello',
|
||||
body: 'World',
|
||||
createdAt: $createdAt,
|
||||
featureSlot: 1,
|
||||
);
|
||||
|
||||
$this->assertSame(7, $post->getId());
|
||||
$this->assertSame(3, $post->getUserId());
|
||||
$this->assertSame('Hello', $post->getTitle());
|
||||
$this->assertSame('World', $post->getBody());
|
||||
$this->assertSame($createdAt, $post->getCreatedAt());
|
||||
$this->assertSame(1, $post->getFeatureSlot());
|
||||
$this->assertTrue($post->isFeatured());
|
||||
}
|
||||
|
||||
public function test_post_with_null_feature_slot_is_not_featured(): void
|
||||
{
|
||||
$post = new Post(
|
||||
id: 1,
|
||||
userId: 1,
|
||||
title: 't',
|
||||
body: 'b',
|
||||
createdAt: new DateTimeImmutable('2026-05-06T12:00:00Z'),
|
||||
featureSlot: null,
|
||||
);
|
||||
|
||||
$this->assertNull($post->getFeatureSlot());
|
||||
$this->assertFalse($post->isFeatured());
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue