<?php

namespace Tests\Unit\SiteReadiness\Checks;

use App\SiteReadiness\Checks\AppDebugCheck;
use App\SiteReadiness\Checks\EncryptionEnabledCheck;
use App\SiteReadiness\Status;
use Tests\TestCase;

class EnvironmentChecksTest extends TestCase
{
    public function test_debug_on_in_production_is_fail(): void
    {
        config(['app.env' => 'production', 'app.debug' => true]);
        $this->assertSame(Status::FAIL, (new AppDebugCheck())->run()->status);
    }

    public function test_debug_on_in_staging_is_warn(): void
    {
        config(['app.env' => 'staging', 'app.debug' => true]);
        $this->assertSame(Status::WARN, (new AppDebugCheck())->run()->status);
    }

    public function test_debug_off_is_ok(): void
    {
        config(['app.env' => 'production', 'app.debug' => false]);
        $this->assertSame(Status::OK, (new AppDebugCheck())->run()->status);
    }

    public function test_encryption_off_in_production_is_fail(): void
    {
        config(['app.env' => 'production', 'encryption.enabled' => false, 'app.key' => 'base64:x']);
        $this->assertSame(Status::FAIL, (new EncryptionEnabledCheck())->run()->status);
    }

    public function test_encryption_on_with_key_is_ok(): void
    {
        config(['app.env' => 'production', 'encryption.enabled' => true, 'app.key' => 'base64:x']);
        $this->assertSame(Status::OK, (new EncryptionEnabledCheck())->run()->status);
    }
}
