<?php

declare(strict_types=1);

namespace Tests\Unit\Framework\Logging;

use App\Framework\Logging\LogChannel;
use PHPUnit\Framework\TestCase;

final class LogChannelTest extends TestCase
{
    public function test_can_get_log_path_key(): void
    {
        expect(LogChannel::APP->getLogPathKey())->toBe('app');
        expect(LogChannel::SECURITY->getLogPathKey())->toBe('security');
        expect(LogChannel::CACHE->getLogPathKey())->toBe('cache');
        expect(LogChannel::DATABASE->getLogPathKey())->toBe('database');
        expect(LogChannel::FRAMEWORK->getLogPathKey())->toBe('framework');
        expect(LogChannel::ERROR->getLogPathKey())->toBe('error');
    }

    public function test_can_get_description(): void
    {
        expect(LogChannel::APP->getDescription())->toBe('Application logs');
        expect(LogChannel::SECURITY->getDescription())->toBe('Security events and authentication logs');
        expect(LogChannel::CACHE->getDescription())->toBe('Cache operations and debugging');
        expect(LogChannel::DATABASE->getDescription())->toBe('Database queries and operations');
        expect(LogChannel::FRAMEWORK->getDescription())->toBe('Framework internals and debugging');
        expect(LogChannel::ERROR->getDescription())->toBe('Error-specific logs');
    }

    public function test_can_get_all_channels(): void
    {
        $channels = LogChannel::getAllChannels();

        expect($channels)->toBeArray();
        expect($channels)->toHaveCount(6);

        expect($channels['app'])->toBe('Application logs');
        expect($channels['security'])->toBe('Security events and authentication logs');
        expect($channels['cache'])->toBe('Cache operations and debugging');
        expect($channels['database'])->toBe('Database queries and operations');
        expect($channels['framework'])->toBe('Framework internals and debugging');
        expect($channels['error'])->toBe('Error-specific logs');
    }

    public function test_enum_values_are_correct(): void
    {
        expect(LogChannel::APP->value)->toBe('app');
        expect(LogChannel::SECURITY->value)->toBe('security');
        expect(LogChannel::CACHE->value)->toBe('cache');
        expect(LogChannel::DATABASE->value)->toBe('database');
        expect(LogChannel::FRAMEWORK->value)->toBe('framework');
        expect(LogChannel::ERROR->value)->toBe('error');
    }

    public function test_all_enum_cases_are_covered(): void
    {
        $expectedCases = ['app', 'security', 'cache', 'database', 'framework', 'error'];
        $actualCases = array_map(fn ($case) => $case->value, LogChannel::cases());

        expect($actualCases)->toBe($expectedCases);
    }
}
