<?php

declare(strict_types=1);

namespace App\Tests\Unit\Module\Core;

use App\Module\Core\CoreModule;
use App\Shared\Domain\Module\ModuleInterface;
use PHPUnit\Framework\TestCase;

/**
 * @internal
 */
final class CoreModuleTest extends TestCase
{
    public function testItIsAModule(): void
    {
        self::assertInstanceOf(ModuleInterface::class, new CoreModule());
    }

    public function testIdentity(): void
    {
        self::assertSame('core', CoreModule::id());
        self::assertTrue(CoreModule::isRequired());
        self::assertNotSame('', CoreModule::label());
    }

    public function testPermissionsAreWellFormed(): void
    {
        foreach (CoreModule::permissions() as $permission) {
            self::assertArrayHasKey('code', $permission);
            self::assertArrayHasKey('label', $permission);
        }
    }

    public function testPermissionsExposeAuditLogView(): void
    {
        $codes = array_column(CoreModule::permissions(), 'code');

        self::assertCount(6, $codes);
        self::assertContains('core.audit_log.view', $codes);
    }
}
