TenantAtlas/tests/Feature/Onboarding/OnboardingSessionLifecycleTest.php
2026-02-01 12:20:18 +01:00

41 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
use App\Models\OnboardingSession;
use App\Models\Tenant;
use App\Models\TenantMembership;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
it('allows an owner to create and resume an onboarding session', function () {
$tenant = Tenant::factory()->create(['status' => 'active']);
$onboardingUrl = "/admin/t/{$tenant->external_id}/onboarding";
$owner = User::factory()->create();
TenantMembership::query()->create([
'tenant_id' => $tenant->getKey(),
'user_id' => $owner->getKey(),
'role' => 'owner',
'source' => 'manual',
'source_ref' => null,
'created_by_user_id' => null,
]);
$this->actingAs($owner);
$this->get($onboardingUrl)
->assertSuccessful();
expect(OnboardingSession::query()->where('tenant_id', $tenant->getKey())->count())
->toBe(1);
$this->get($onboardingUrl)
->assertSuccessful();
expect(OnboardingSession::query()->where('tenant_id', $tenant->getKey())->count())
->toBe(1);
});