1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 19:34:04 +00:00

Test that the prefix stays the same

This commit is contained in:
lukinovec 2023-01-05 13:05:39 +01:00
parent 86c388a2b6
commit ffefe1b45c

View file

@ -217,10 +217,16 @@ test('stores other than the default one are not prefixed', function () {
});
test('drivers specified in the nonTenantCacheDrivers property do not get prefixed', function() {
$defaultPrefix = config('cache.prefix');
PrefixCacheTenancyBootstrapper::$nonTenantCacheDrivers[] = config('cache.default');
$expectPrefixToBeAnEmptyString = fn() => expect($defaultPrefix . ':')
->toBe(app('cache')->getPrefix())
->toBe(app('cache.store')->getPrefix());
$this->app->singleton(CacheService::class);
app()->make(CacheService::class)->handle();
$expectPrefixToBeAnEmptyString();
expect(cache('key'))->toBe('central-value');
@ -230,15 +236,18 @@ test('drivers specified in the nonTenantCacheDrivers property do not get prefixe
expect(cache('key'))->toBe('central-value');
app()->make(CacheService::class)->handle();
$expectPrefixToBeAnEmptyString();
expect(cache('key'))->toBe($tenant1->getTenantKey());
tenancy()->initialize($tenant2);
expect(cache('key'))->toBe($tenant1->getTenantKey());
app()->make(CacheService::class)->handle();
$expectPrefixToBeAnEmptyString();
expect(cache('key'))->toBe($tenant2->getTenantKey());
tenancy()->end();
$expectPrefixToBeAnEmptyString();
expect(cache('key'))->toBe($tenant2->getTenantKey());
});