From 6d303d1b2ea2faabf10a38c21a834c0e6d74ce90 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Mon, 10 Oct 2022 17:37:58 +0200 Subject: [PATCH] Test that `migrate:fresh` deletes tenant databases --- tests/CommandsTest.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/CommandsTest.php b/tests/CommandsTest.php index 219d87b4..828f2aee 100644 --- a/tests/CommandsTest.php +++ b/tests/CommandsTest.php @@ -267,6 +267,25 @@ test('run command works when sub command asks questions and accepts arguments', expect($user->email)->toBe('email@localhost'); }); +test('migrate fresh command deletes tenant databases', function() { + /** @var Tenant[] $tenants */ + $tenants = [ + Tenant::create(), + Tenant::create(), + Tenant::create(), + ]; + + foreach ($tenants as $tenant) { + expect($tenant->database()->manager()->databaseExists($tenant->database()->getName()))->toBeTrue(); + } + + pest()->artisan('migrate:fresh'); + + foreach ($tenants as $tenant) { + expect($tenant->database()->manager()->databaseExists($tenant->database()->getName()))->toBeFalse(); + } +}); + // todo@tests function runCommandWorks(): void {