79 lines
3.4 KiB
PHP
79 lines
3.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
it('Spec414 required kernel definition tables do not introduce ownership columns', function () {
|
|
foreach (['tenant_configuration_resource_types', 'tenant_configuration_supported_scopes'] as $table) {
|
|
expect(Schema::hasTable($table))->toBeTrue();
|
|
|
|
$columns = Schema::getColumnListing($table);
|
|
|
|
expect($columns)
|
|
->not->toContain('tenant_id')
|
|
->not->toContain('workspace_id')
|
|
->not->toContain('managed_environment_id')
|
|
->not->toContain('provider_connection_id');
|
|
}
|
|
});
|
|
|
|
it('Spec414 keeps provider-native tenant identifiers out of Coverage v2 ownership schema', function () {
|
|
$coverageColumns = collect([
|
|
...Schema::getColumnListing('tenant_configuration_resource_types'),
|
|
...Schema::getColumnListing('tenant_configuration_supported_scopes'),
|
|
]);
|
|
|
|
expect($coverageColumns->filter(
|
|
fn (string $column): bool => str_contains($column, 'tenant_id')
|
|
|| str_contains($column, 'entra_tenant_id')
|
|
|| str_contains($column, 'provider_tenant_id')
|
|
|| str_contains($column, 'source_tenant_id')
|
|
|| str_contains($column, 'external_tenant_id')
|
|
)->values()->all())->toBe([]);
|
|
});
|
|
|
|
it('Spec414 keeps historical migration seed semantics independent from mutable runtime defaults', function () {
|
|
$migration = file_get_contents(database_path('migrations/2026_06_25_000414_create_tenant_configuration_kernel_tables.php'));
|
|
|
|
expect($migration)->not->toContain('App\\Services\\TenantConfiguration\\ResourceTypeRegistry')
|
|
->not->toContain('App\\Services\\TenantConfiguration\\SupportedScopeResolver')
|
|
->not->toContain('App\\Support\\TenantConfiguration')
|
|
->and($migration)->toContain('private function resourceTypeDefinitions')
|
|
->toContain('private function supportedScopeDefinitions')
|
|
->toContain('private const SOURCE_CLASSES');
|
|
});
|
|
|
|
it('Spec414 proves PostgreSQL JSONB and check constraints for kernel definitions', function () {
|
|
if (DB::getDriverName() !== 'pgsql') {
|
|
$this->markTestSkipped('PostgreSQL-specific Coverage v2 kernel schema proof runs in the pgsql lane.');
|
|
}
|
|
|
|
$columns = collect(DB::select(<<<'SQL'
|
|
SELECT table_name, column_name, data_type
|
|
FROM information_schema.columns
|
|
WHERE table_name IN ('tenant_configuration_resource_types', 'tenant_configuration_supported_scopes')
|
|
AND column_name IN ('metadata', 'included_resource_types')
|
|
SQL))->mapWithKeys(
|
|
fn (object $row): array => [$row->table_name.'.'.$row->column_name => $row->data_type],
|
|
);
|
|
|
|
expect($columns['tenant_configuration_resource_types.metadata'])->toBe('jsonb')
|
|
->and($columns['tenant_configuration_supported_scopes.metadata'])->toBe('jsonb')
|
|
->and($columns['tenant_configuration_supported_scopes.included_resource_types'])->toBe('jsonb');
|
|
|
|
$constraints = collect(DB::select(<<<'SQL'
|
|
SELECT conname
|
|
FROM pg_constraint
|
|
WHERE conrelid IN (
|
|
'tenant_configuration_resource_types'::regclass,
|
|
'tenant_configuration_supported_scopes'::regclass
|
|
)
|
|
SQL))->pluck('conname')->all();
|
|
|
|
expect($constraints)
|
|
->toContain('tenant_config_resource_types_source_class_check')
|
|
->toContain('tenant_config_supported_scopes_denominator_array_check');
|
|
});
|