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

use initialize() twice without end()ing tenancy to assert that previousConnection logic works correctly

This commit is contained in:
Samuel Štancl 2022-09-26 14:02:48 +02:00 committed by GitHub
parent 989e2368ca
commit 395d8597bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -24,15 +24,17 @@ beforeEach(function () {
test('batch repository is set to tenant connection and reverted', function () { test('batch repository is set to tenant connection and reverted', function () {
$tenant = Tenant::create(); $tenant = Tenant::create();
$tenant2 = Tenant::create();
expect(getBatchRepositoryConnectionName())->toBe('central'); expect(getBatchRepositoryConnectionName())->toBe('central');
tenancy()->initialize($tenant); tenancy()->initialize($tenant);
expect(getBatchRepositoryConnectionName())->toBe('tenant');
tenancy()->initialize($tenant2);
expect(getBatchRepositoryConnectionName())->toBe('tenant'); expect(getBatchRepositoryConnectionName())->toBe('tenant');
tenancy()->end(); tenancy()->end();
expect(getBatchRepositoryConnectionName())->toBe('central'); expect(getBatchRepositoryConnectionName())->toBe('central');
})->skip(fn() => version_compare(app()->version(), '8.0', '<'), 'Job batches are only supported in Laravel 8+'); })->skip(fn() => version_compare(app()->version(), '8.0', '<'), 'Job batches are only supported in Laravel 8+');