<?php

declare(strict_types=1);

it('keeps the canonical shared tenant helper profile catalog explicit and reviewable', function (): void {
    $profiles = createUserWithTenantProfileCatalog();

    expect($profiles)->toHaveKeys([
        'minimal',
        'standard',
        'full',
    ])
        ->and($profiles['minimal'])->toMatchArray([
            'workspace' => true,
            'membership' => true,
            'session' => true,
            'provider' => false,
            'credential' => false,
            'cache' => false,
            'uiContext' => false,
        ])
        ->and($profiles['standard'])->toMatchArray([
            'workspace' => true,
            'membership' => true,
            'session' => true,
            'provider' => true,
            'credential' => false,
            'cache' => false,
            'uiContext' => false,
        ])
        ->and($profiles['full'])->toMatchArray([
            'workspace' => true,
            'membership' => true,
            'session' => true,
            'provider' => true,
            'credential' => true,
            'cache' => true,
            'uiContext' => true,
        ]);
});

it('keeps the temporary legacy fixture aliases explicit and reviewable', function (): void {
    $aliases = createUserWithTenantLegacyProfileAliases();

    expect($aliases)->toHaveKeys([
        'provider-enabled',
        'credential-enabled',
        'ui-context',
        'heavy',
    ])
        ->and($aliases['provider-enabled']['profile'])->toBe('standard')
        ->and($aliases['credential-enabled']['profile'])->toBe('full')
        ->and($aliases['ui-context']['profile'])->toBe('full')
        ->and($aliases['heavy']['profile'])->toBe('full')
        ->and($aliases['provider-enabled']['removalTrigger'])->not->toBe('')
        ->and($aliases['credential-enabled']['removalTrigger'])->not->toBe('')
        ->and($aliases['ui-context']['removalTrigger'])->not->toBe('')
        ->and($aliases['heavy']['removalTrigger'])->not->toBe('');
});

it('resolves legacy aliases to the promised side-effect bundles', function (): void {
    $credentialEnabled = resolveCreateUserWithTenantProfile('credential-enabled');
    $uiContext = resolveCreateUserWithTenantProfile('ui-context');

    expect($credentialEnabled['canonicalProfile'])->toBe('full')
        ->and($credentialEnabled['legacyAlias'])->toBe('credential-enabled')
        ->and($credentialEnabled['sideEffects'])->toMatchArray([
            'provider' => true,
            'credential' => true,
            'cache' => false,
            'uiContext' => false,
        ])
        ->and($uiContext['canonicalProfile'])->toBe('full')
        ->and($uiContext['legacyAlias'])->toBe('ui-context')
        ->and($uiContext['sideEffects'])->toMatchArray([
            'provider' => false,
            'credential' => false,
            'cache' => true,
            'uiContext' => true,
        ]);
});