<?php

namespace Tests\Feature;

use App\Services\Installer\ServerRequirementsChecker;
use Tests\TestCase;

class ServerRequirementsCheckerTest extends TestCase
{
    public function test_checker_returns_structured_results(): void
    {
        $checker = app(ServerRequirementsChecker::class);
        $results = $checker->check();

        $this->assertArrayHasKey('passed', $results);
        $this->assertArrayHasKey('php_version', $results);
        $this->assertArrayHasKey('extensions', $results);
        $this->assertArrayHasKey('writable_paths', $results);
        $this->assertArrayHasKey('current', $results['php_version']);
        $this->assertArrayHasKey('required', $results['php_version']);
    }

    public function test_required_extensions_are_checked(): void
    {
        $checker = app(ServerRequirementsChecker::class);
        $results = $checker->check();

        foreach (config('installer.php.extensions') as $extension) {
            $this->assertArrayHasKey($extension, $results['extensions']);
            $this->assertTrue($results['extensions'][$extension]['passed']);
        }
    }
}
