<?php

namespace Tests\Unit\Services;

use App\Services\SystemStatusService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Http;
use Tests\TestCase;

class SystemStatusServiceTest extends TestCase
{
    use RefreshDatabase;

    protected function setUp(): void
    {
        parent::setUp();

        // Mock HTTP requests to prevent external calls
        Http::fake([
            '*' => Http::response('', 500),
        ]);
    }

    public function test_service_instantiation(): void
    {
        $service = new SystemStatusService;
        $this->assertInstanceOf(SystemStatusService::class, $service);
    }

    public function test_get_system_status_returns_correct_structure(): void
    {
        $service = new SystemStatusService;
        $status = $service->getSystemStatus();

        $this->assertIsArray($status);
        $this->assertArrayHasKey('is_enabled', $status);
        $this->assertArrayHasKey('status', $status);
        $this->assertArrayHasKey('status_class', $status);
        $this->assertArrayHasKey('reasons', $status);

        // Without database setup, system should be disabled
        $this->assertFalse($status['is_enabled']);
        $this->assertEquals('Disabled', $status['status']);
        $this->assertEquals('text-red-600', $status['status_class']);
        $this->assertIsArray($status['reasons']);
    }
}
