1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-04 19:24:02 +00:00

Test that the tenant connections get closed after jobs get processed

This commit is contained in:
lukinovec 2023-06-22 10:45:27 +02:00
parent 42dc85666f
commit c5d98aee33

View file

@ -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';