From c5d98aee332127ee72b25d7143772d4482c40d59 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Thu, 22 Jun 2023 10:45:27 +0200 Subject: [PATCH] Test that the tenant connections get closed after jobs get processed --- tests/QueueTest.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/QueueTest.php b/tests/QueueTest.php index fca2e04f..4529dbcb 100644 --- a/tests/QueueTest.php +++ b/tests/QueueTest.php @@ -181,6 +181,20 @@ test('the tenant used by the job doesnt change when the current tenant changes', expect(pest()->valuestore->get('tenant_id'))->toBe('The current tenant id is: acme'); }); +test('tenant connections do not persist after tenant jobs get processed', function() { + withTenantDatabases(); + + $tenant = Tenant::create(); + + tenancy()->initialize($tenant); + + dispatch(new TestJob(pest()->valuestore)); + + pest()->artisan('queue:work --once'); + + expect(collect(DB::select('SHOW FULL PROCESSLIST'))->pluck('db'))->not()->toContain($tenant->database()->getName()); +}); + function createValueStore(): void { $valueStorePath = __DIR__ . '/Etc/tmp/queuetest.json';