From 395d8597bb0b041ce13f637b5d8b915c42b80695 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Mon, 26 Sep 2022 14:02:48 +0200 Subject: [PATCH] use initialize() twice without end()ing tenancy to assert that previousConnection logic works correctly --- tests/BatchTest.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/BatchTest.php b/tests/BatchTest.php index a401dbc7..a168deb2 100644 --- a/tests/BatchTest.php +++ b/tests/BatchTest.php @@ -24,15 +24,17 @@ beforeEach(function () { test('batch repository is set to tenant connection and reverted', function () { $tenant = Tenant::create(); + $tenant2 = Tenant::create(); expect(getBatchRepositoryConnectionName())->toBe('central'); tenancy()->initialize($tenant); - + expect(getBatchRepositoryConnectionName())->toBe('tenant'); + + tenancy()->initialize($tenant2); expect(getBatchRepositoryConnectionName())->toBe('tenant'); tenancy()->end(); - expect(getBatchRepositoryConnectionName())->toBe('central'); })->skip(fn() => version_compare(app()->version(), '8.0', '<'), 'Job batches are only supported in Laravel 8+');