44 lines
1.3 KiB
PHP
44 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Filament\Resources\ProviderConnectionResource\Pages\EditProviderConnection;
|
|
use App\Models\Tenant;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
test('EditProviderConnection prefers scoped tenant external id over Tenant::current', function (): void {
|
|
$tenantA = Tenant::factory()->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();
|
|
});
|