Implements Spec 081 provider-connection cutover. Highlights: - Adds provider connection resolution + gating for operations/verification. - Adds provider credential observer wiring. - Updates Filament tenant verify flow to block with next-steps when provider connection isn’t ready. - Adds spec docs under specs/081-provider-connection-cutover/ and extensive Spec081 test coverage. Tests: - vendor/bin/sail artisan test --compact tests/Feature/Filament/TenantSetupTest.php - Focused suites for ProviderConnections/Verification ran during implementation (see local logs). Co-authored-by: Ahmed Darrazi <ahmeddarrazi@MacBookPro.fritz.box> Reviewed-on: #98
59 lines
1.7 KiB
PHP
59 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Models\ProviderConnection;
|
|
use App\Models\Tenant;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
it('Spec081 keeps the partial unique default index for provider connections', function (): void {
|
|
$driver = DB::connection()->getDriverName();
|
|
|
|
if ($driver === 'sqlite') {
|
|
$indexes = collect(DB::select("PRAGMA index_list('provider_connections')"))
|
|
->map(static fn (object $row): array => (array) $row);
|
|
|
|
expect($indexes->pluck('name')->all())->toContain('provider_connections_default_unique');
|
|
|
|
return;
|
|
}
|
|
|
|
$exists = DB::table('pg_indexes')
|
|
->where('tablename', 'provider_connections')
|
|
->where('indexname', 'provider_connections_default_unique')
|
|
->exists();
|
|
|
|
expect($exists)->toBeTrue();
|
|
});
|
|
|
|
it('Spec081 makeDefault preserves one default per tenant and provider', function (): void {
|
|
$tenant = Tenant::factory()->create();
|
|
|
|
$first = ProviderConnection::factory()->create([
|
|
'tenant_id' => (int) $tenant->getKey(),
|
|
'provider' => 'microsoft',
|
|
'is_default' => true,
|
|
]);
|
|
|
|
$second = ProviderConnection::factory()->create([
|
|
'tenant_id' => (int) $tenant->getKey(),
|
|
'provider' => 'microsoft',
|
|
'is_default' => false,
|
|
]);
|
|
|
|
$second->makeDefault();
|
|
|
|
$defaults = ProviderConnection::query()
|
|
->where('tenant_id', (int) $tenant->getKey())
|
|
->where('provider', 'microsoft')
|
|
->where('is_default', true)
|
|
->pluck('id')
|
|
->all();
|
|
|
|
expect($defaults)->toHaveCount(1)
|
|
->and((int) $defaults[0])->toBe((int) $second->getKey());
|
|
|
|
$first->refresh();
|
|
expect((bool) $first->is_default)->toBeFalse();
|
|
});
|