TenantAtlas/apps/platform/tests/Unit/Tenants/TenantLifecycleTest.php
Ahmed Darrazi 1123b122d9
Some checks failed
PR Fast Feedback / fast-feedback (pull_request) Failing after 7m13s
feat: cut over tenant core to managed environments
2026-05-07 08:35:42 +02:00

30 lines
1.0 KiB
PHP

<?php
declare(strict_types=1);
use App\Models\ManagedEnvironment;
use App\Support\Tenants\TenantLifecycle;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
it('normalizes canonical lifecycle values only', function (string $input, TenantLifecycle $expected): void {
expect(TenantLifecycle::tryFromValue($input))->toBe($expected);
})->with([
'draft' => ['draft', TenantLifecycle::Draft],
'onboarding' => ['onboarding', TenantLifecycle::Onboarding],
'active' => ['active', TenantLifecycle::Active],
'archived' => ['archived', TenantLifecycle::Archived],
]);
it('returns null for non-canonical lifecycle aliases', function (): void {
expect(TenantLifecycle::tryFromValue('pending'))->toBeNull()
->and(TenantLifecycle::tryFromValue('inactive'))->toBeNull();
});
it('derives archived lifecycle from soft-deleted tenants', function (): void {
$tenant = ManagedEnvironment::factory()->archived()->create();
expect(TenantLifecycle::fromTenant($tenant))->toBe(TenantLifecycle::Archived);
});