78 lines
2.3 KiB
PHP
78 lines
2.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
|
use Illuminate\Support\Facades\Artisan;
|
|
use Illuminate\Support\Facades\Schema;
|
|
use PHPUnit\Framework\Attributes\Group;
|
|
use Tests\TestCase;
|
|
|
|
/**
|
|
* Sanity-checks the Form Builder migration chain after S2a.
|
|
*
|
|
* Post-S2a: the legacy registration_* tables are DROPPED by a one-way
|
|
* migration (2026_04_20_100000_drop_remaining_legacy_registration_tables).
|
|
* Rolling back that migration throws by design — restoring the legacy
|
|
* tables from the new form_* structure would be lossy.
|
|
*
|
|
* Tagged "slow" because it exercises the real migrator.
|
|
*/
|
|
#[Group('slow')]
|
|
final class MigrationRollbackTest extends TestCase
|
|
{
|
|
use WithoutMiddleware;
|
|
|
|
private const FORM_BUILDER_TABLES = [
|
|
'user_profiles',
|
|
'form_schemas',
|
|
'form_schema_sections',
|
|
'form_field_library',
|
|
'form_fields',
|
|
'form_submissions',
|
|
'form_submission_section_statuses',
|
|
'form_submission_delegations',
|
|
'form_values',
|
|
'form_value_options',
|
|
'form_templates',
|
|
'form_schema_webhooks',
|
|
'form_webhook_deliveries',
|
|
];
|
|
|
|
private const LEGACY_TABLES = [
|
|
'registration_form_fields',
|
|
'person_field_values',
|
|
'registration_field_templates',
|
|
];
|
|
|
|
public function test_form_builder_tables_present_after_migrate_fresh(): void
|
|
{
|
|
Artisan::call('migrate:fresh');
|
|
|
|
foreach (self::FORM_BUILDER_TABLES as $table) {
|
|
$this->assertTrue(Schema::hasTable($table), "{$table} should exist after migrate:fresh");
|
|
}
|
|
|
|
foreach (self::LEGACY_TABLES as $legacy) {
|
|
$this->assertFalse(
|
|
Schema::hasTable($legacy),
|
|
"legacy table {$legacy} should NOT exist after S2a purge"
|
|
);
|
|
}
|
|
}
|
|
|
|
public function test_drop_legacy_tables_migration_is_one_way(): void
|
|
{
|
|
Artisan::call('migrate:fresh');
|
|
|
|
// step=1 targets the most recent migration — the S2a drop —
|
|
// whose down() is a hard failure.
|
|
$this->expectException(\RuntimeException::class);
|
|
$this->expectExceptionMessage('Legacy registration tables cannot be restored');
|
|
|
|
Artisan::call('migrate:rollback', ['--step' => 1]);
|
|
}
|
|
}
|