<?php

declare(strict_types=1);

use Builder\Core\Foundation\Registry;

it('getRegisteredPermissions() returns empty array by default', function (): void {
    $registry = new Registry;

    expect($registry->getRegisteredPermissions())->toBe([]);
});

it('permissions() registers a single permission', function (): void {
    $registry = new Registry;
    $registry->permissions('view:analytics');

    expect($registry->getRegisteredPermissions())->toBe(['view:analytics']);
});

it('permissions() registers multiple permissions at once', function (): void {
    $registry = new Registry;
    $registry->permissions('view:analytics', 'export:reports');

    expect($registry->getRegisteredPermissions())->toBe(['view:analytics', 'export:reports']);
});

it('permissions() is variadic and can be called multiple times', function (): void {
    $registry = new Registry;
    $registry->permissions('view:analytics');
    $registry->permissions('export:reports', 'manage:billing');

    expect($registry->getRegisteredPermissions())->toBe([
        'view:analytics',
        'export:reports',
        'manage:billing',
    ]);
});

it('permissions() returns self for fluent chaining', function (): void {
    $registry = new Registry;

    expect($registry->permissions('view:analytics'))->toBe($registry);
});
