create(); $tenantB = Tenant::factory()->create(); $tenantB->makeCurrent(); $page = app(EditProviderConnection::class); $page->scopedTenantExternalId = (string) $tenantA->external_id; $method = new ReflectionMethod($page, 'currentTenant'); $method->setAccessible(true); $resolvedTenant = $method->invoke($page); expect($resolvedTenant)->toBeInstanceOf(Tenant::class); expect($resolvedTenant->is($tenantA))->toBeTrue(); }); test('EditProviderConnection falls back to Tenant::current when no scoped tenant is set', function (): void { $tenantA = Tenant::factory()->create(); $tenantA->makeCurrent(); $page = app(EditProviderConnection::class); $method = new ReflectionMethod($page, 'currentTenant'); $method->setAccessible(true); $resolvedTenant = $method->invoke($page); expect($resolvedTenant)->toBeInstanceOf(Tenant::class); expect($resolvedTenant->is($tenantA))->toBeTrue(); });