Files

36 lines
1.2 KiB
PHP

<?php
namespace Tests\Unit\Resources\Notifications;
use App\Http\Resources\Notifications\UserNotificationResource;
use Tests\TestCase;
class UserNotificationResourceTest extends TestCase
{
public function test_resource_returns_expected_shape(): void
{
$resource = new UserNotificationResource([
'notification_id' => 10,
'title' => 'Title',
'message' => 'Message',
'priority' => 'high',
'scheduled_at' => '2025-01-01 00:00:00',
'expires_at' => '2025-01-02 00:00:00',
'target_group' => 'parent',
'is_read' => 1,
]);
$payload = $resource->toArray(request());
$this->assertArrayHasKey('notification_id', $payload);
$this->assertArrayHasKey('title', $payload);
$this->assertArrayHasKey('message', $payload);
$this->assertArrayHasKey('priority', $payload);
$this->assertArrayHasKey('scheduled_at', $payload);
$this->assertArrayHasKey('expires_at', $payload);
$this->assertArrayHasKey('target_group', $payload);
$this->assertArrayHasKey('is_read', $payload);
$this->assertTrue($payload['is_read']);
}
}