## Summary - implement Spec 143 tenant lifecycle, operability, and tenant-context semantics across chooser, tenant management, onboarding, and canonical operation viewers - add centralized tenant lifecycle and operability support types, audit action coverage, and lifecycle-aware badge and action handling - add feature and unit coverage for tenant chooser eligibility, global search scoping, canonical operation access, onboarding authorization, and lifecycle presentation ## Testing - vendor/bin/sail artisan test --compact - vendor/bin/sail bin pint --dirty --format agent Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #172
70 lines
1.9 KiB
PHP
70 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Models\Tenant;
|
|
use App\Services\Tenants\TenantOperabilityService;
|
|
use App\Support\Tenants\TenantLifecycle;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
it('returns lifecycle-aware operability decisions for every canonical tenant state', function (
|
|
\Closure $tenantFactory,
|
|
TenantLifecycle $expectedLifecycle,
|
|
bool $canSelectAsContext,
|
|
bool $canOperate,
|
|
bool $canArchive,
|
|
bool $canRestore,
|
|
bool $canResumeOnboarding,
|
|
): void {
|
|
$tenant = $tenantFactory();
|
|
$decision = app(TenantOperabilityService::class)->decisionFor($tenant);
|
|
|
|
expect($decision->lifecycle)->toBe($expectedLifecycle)
|
|
->and($decision->canViewTenantSurface)->toBeTrue()
|
|
->and($decision->canSelectAsContext)->toBe($canSelectAsContext)
|
|
->and($decision->canOperate)->toBe($canOperate)
|
|
->and($decision->canArchive)->toBe($canArchive)
|
|
->and($decision->canRestore)->toBe($canRestore)
|
|
->and($decision->canResumeOnboarding)->toBe($canResumeOnboarding)
|
|
->and($decision->canReferenceInWorkspaceMonitoring)->toBeTrue();
|
|
})->with([
|
|
'draft' => [
|
|
fn (): Tenant => Tenant::factory()->draft()->create(),
|
|
TenantLifecycle::Draft,
|
|
false,
|
|
false,
|
|
true,
|
|
false,
|
|
true,
|
|
],
|
|
'onboarding' => [
|
|
fn (): Tenant => Tenant::factory()->onboarding()->create(),
|
|
TenantLifecycle::Onboarding,
|
|
false,
|
|
false,
|
|
true,
|
|
false,
|
|
true,
|
|
],
|
|
'active' => [
|
|
fn (): Tenant => Tenant::factory()->active()->create(),
|
|
TenantLifecycle::Active,
|
|
true,
|
|
true,
|
|
true,
|
|
false,
|
|
false,
|
|
],
|
|
'archived' => [
|
|
fn (): Tenant => Tenant::factory()->archived()->create(),
|
|
TenantLifecycle::Archived,
|
|
false,
|
|
false,
|
|
false,
|
|
true,
|
|
false,
|
|
],
|
|
]);
|