<?php

namespace Tests\Unit\Services\Administrator;

use App\Services\Administrator\AdminNotificationSubjectService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;

class AdminNotificationSubjectServiceTest extends TestCase
{
    use RefreshDatabase;

    public function test_alerts_data_includes_admins(): void
    {
        DB::table('roles')->insert([
            ['id' => 1, 'name' => 'Admin', 'slug' => 'admin', 'dashboard_route' => 'admin', 'priority' => 1, 'is_active' => 1],
        ]);

        DB::table('users')->insert([
            'id' => 1,
            'school_id' => 1,
            'firstname' => 'Admin',
            'lastname' => 'User',
            'cellphone' => '5555555555',
            'email' => 'admin@example.com',
            'address_street' => '123 Main',
            'city' => 'City',
            'state' => 'ST',
            'zip' => '12345',
            'accept_school_policy' => 1,
            'is_verified' => 1,
            'status' => 'Active',
            'is_suspended' => 0,
            'failed_attempts' => 0,
            'password' => bcrypt('secret'),
            'semester' => 'Fall',
            'school_year' => '2025-2026',
        ]);

        DB::table('user_roles')->insert([
            'id' => 1,
            'user_id' => 1,
            'role_id' => 1,
        ]);

        $userService = new \App\Services\Administrator\AdminNotificationUserService();
        $service = new AdminNotificationSubjectService($userService);

        $data = $service->alertsData();

        $this->assertTrue($data['tableReady']);
        $this->assertCount(1, $data['admins']);
    }
}
