From ffefe1b45ce307d9b32705363ce9191a004f0658 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Thu, 5 Jan 2023 13:05:39 +0100 Subject: [PATCH] Test that the prefix stays the same --- tests/PrefixCacheBootstrapperTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/PrefixCacheBootstrapperTest.php b/tests/PrefixCacheBootstrapperTest.php index 8181de8a..f547a99a 100644 --- a/tests/PrefixCacheBootstrapperTest.php +++ b/tests/PrefixCacheBootstrapperTest.php @@ -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()); });