<?php

namespace Tests\Unit\Services\Administrator;

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

class AdminPrintRecipientServiceTest extends TestCase
{
    use RefreshDatabase;

    public function test_data_returns_admins_and_assigned(): 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,
        ]);

        DB::table('admin_notification_subjects')->insert([
            'id' => 1,
            'admin_id' => 1,
            'subject' => 'print_requests',
        ]);

        $service = new AdminPrintRecipientService(new \App\Services\Administrator\AdminNotificationUserService());
        $data = $service->data();

        $this->assertTrue($data['assigned'][1]);
    }
}
