From 3ecaddca12fc3a517101f9b3cd09df3dde635a02 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Mon, 6 Apr 2026 08:30:57 +0200 Subject: [PATCH] dump command: test dump content The TenantDump command should generate a dump with tenant tables only. --- tests/CommandsTest.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/CommandsTest.php b/tests/CommandsTest.php index a5b3b8566..829515a89 100644 --- a/tests/CommandsTest.php +++ b/tests/CommandsTest.php @@ -259,6 +259,30 @@ expect($schemaPath)->toBeFile(); }); +test('dump command generates a dump that only contains tenant tables', function () { + $schemaPath = 'tests/Etc/tenant-schema-test.dump'; + $centralTables = ['domains', 'tenants']; + $tenantTables = ['users']; + + $tenant1 = Tenant::create(); + + Artisan::call('tenants:migrate'); + + Artisan::call("tenants:dump --tenant='$tenant1->id' --path='$schemaPath'"); + + $dumpContent = file_get_contents($schemaPath); + + // The dump includes tenant tables + foreach ($tenantTables as $table) { + expect($dumpContent)->toContain("CREATE TABLE `$table`"); + } + + // The dump doesn't include central-only tables + foreach ($centralTables as $table) { + expect($dumpContent)->not()->toContain("CREATE TABLE `$table`"); + } +}); + test('rollback command works', function () { $tenant = Tenant::create(); Artisan::call('tenants:migrate');