<?php

use CodeIgniter\Test\CIUnitTestCase;
use CodeIgniter\Test\FeatureTestTrait;

/**
 * @internal
 */
final class HealthControllerTest extends CIUnitTestCase
{
    use FeatureTestTrait;

    public function testHealthEndpointReturnsOk(): void
    {
        $result = $this->get('health');

        $result->assertStatus(200);
        $result->assertHeader('Content-Type', 'application/json; charset=UTF-8');
        $json = json_decode($result->response()->getBody(), true);
        $this->assertIsArray($json);
        $this->assertArrayHasKey('status', $json);
        $this->assertContains($json['status'], ['healthy', 'degraded'], true);
    }
}
