48 lines
1.3 KiB
PHP
48 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit\Services\Notifications;
|
|
|
|
use App\Services\Notifications\NotificationShowService;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Tests\TestCase;
|
|
|
|
class NotificationShowServiceTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_get_for_user_returns_notification(): void
|
|
{
|
|
DB::table('notifications')->insert([
|
|
'id' => 1,
|
|
'title' => 'Hello',
|
|
'message' => 'Message',
|
|
'target_group' => 'parent',
|
|
'delivery_channels' => json_encode(['in_app']),
|
|
'scheduled_at' => now()->subHour(),
|
|
'created_at' => now(),
|
|
'updated_at' => now(),
|
|
]);
|
|
|
|
DB::table('user_notifications')->insert([
|
|
'notification_id' => 1,
|
|
'user_id' => 1,
|
|
'is_read' => 0,
|
|
]);
|
|
|
|
$service = new NotificationShowService;
|
|
$row = $service->getForUser(1, 1);
|
|
|
|
$this->assertNotNull($row);
|
|
$this->assertSame(1, $row['notification_id']);
|
|
}
|
|
|
|
public function test_get_for_user_returns_null_when_missing(): void
|
|
{
|
|
$service = new NotificationShowService;
|
|
$row = $service->getForUser(1, 99);
|
|
|
|
$this->assertNull($row);
|
|
}
|
|
}
|