Files
L-Ami-Fiduciaire/tests/Feature/Database/RenameFoldersToDeclarationsTest.php
Saad Ibn-Ezzoubayr fd43a6f429 feat: complete Epic 0 — foundation migration & infrastructure setup
Stories 0.2-0.5: rename folders→declarations (backend+frontend), configure
Redis for cache/queue/sessions, add foundation database migrations
(permissions, archived_at), replace DeclarationStatus enum with architecture
lifecycle values, create DeclarationObserver for status transition validation
and auto-archive, fix controller status transitions to respect observer rules.

93 tests pass (240 assertions).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 18:25:32 +00:00

52 lines
2.1 KiB
PHP

<?php
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
test('declarations table exists after migration', function () {
expect(Schema::hasTable('declarations'))->toBeTrue();
expect(Schema::hasTable('folders'))->toBeFalse();
});
test('declaration_invitations table exists after migration', function () {
expect(Schema::hasTable('declaration_invitations'))->toBeTrue();
expect(Schema::hasTable('folder_invitations'))->toBeFalse();
});
test('messages table has declaration_id column instead of folder_id', function () {
expect(Schema::hasColumn('messages', 'declaration_id'))->toBeTrue();
expect(Schema::hasColumn('messages', 'folder_id'))->toBeFalse();
});
test('declaration_invitations table has declaration_id column instead of folder_id', function () {
expect(Schema::hasColumn('declaration_invitations', 'declaration_id'))->toBeTrue();
expect(Schema::hasColumn('declaration_invitations', 'folder_id'))->toBeFalse();
});
test('composite index exists on messages declaration_id and created_at', function () {
$indexes = collect(DB::select("PRAGMA index_list('messages')"));
$indexColumns = $indexes->flatMap(function ($index) {
return collect(DB::select("PRAGMA index_info('{$index->name}')"))
->pluck('name')
->all();
});
expect($indexColumns->contains('declaration_id'))->toBeTrue();
expect($indexColumns->contains('created_at'))->toBeTrue();
});
test('migration is reversible and rollback restores folder tables', function () {
// Rollback foundation migrations (3) + polymorphic update + rename migration
$this->artisan('migrate:rollback', ['--step' => 5]);
expect(Schema::hasTable('folders'))->toBeTrue();
expect(Schema::hasTable('declarations'))->toBeFalse();
expect(Schema::hasTable('folder_invitations'))->toBeTrue();
expect(Schema::hasTable('declaration_invitations'))->toBeFalse();
expect(Schema::hasColumn('messages', 'folder_id'))->toBeTrue();
expect(Schema::hasColumn('messages', 'declaration_id'))->toBeFalse();
// Re-apply to leave DB in correct state for other tests
$this->artisan('migrate');
});