<?php

namespace Tests\Unit\Services\Notifications;

use App\Services\Notifications\NotificationReadService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;

class NotificationReadServiceTest extends TestCase
{
    use RefreshDatabase;

    public function test_mark_read_updates_row(): void
    {
        DB::table('user_notifications')->insert([
            'notification_id' => 1,
            'user_id' => 1,
            'is_read' => 0,
        ]);

        $service = new NotificationReadService();
        $result = $service->markRead(1, 1);

        $this->assertTrue($result);
        $this->assertDatabaseHas('user_notifications', [
            'notification_id' => 1,
            'user_id' => 1,
            'is_read' => 1,
        ]);
    }

    public function test_mark_read_returns_false_when_missing(): void
    {
        $service = new NotificationReadService();

        $this->assertFalse($service->markRead(1, 99));
    }
}
