From 7ebfc375d6ef0f43311544b26750020b9f905a6f Mon Sep 17 00:00:00 2001 From: lukinovec Date: Tue, 11 Apr 2023 14:28:28 +0200 Subject: [PATCH] Disable cache tagging by default, add CacheTagBootstrapper --- src/Bootstrappers/CacheTagBootstrapper.php | 22 ++++++++++++++++++++++ src/CacheManager.php | 2 +- tests/BootstrapperTest.php | 7 ++----- tests/CacheManagerTest.php | 5 ++--- tests/GlobalCacheTest.php | 7 ++++--- 5 files changed, 31 insertions(+), 12 deletions(-) create mode 100644 src/Bootstrappers/CacheTagBootstrapper.php diff --git a/src/Bootstrappers/CacheTagBootstrapper.php b/src/Bootstrappers/CacheTagBootstrapper.php new file mode 100644 index 00000000..3721e9db --- /dev/null +++ b/src/Bootstrappers/CacheTagBootstrapper.php @@ -0,0 +1,22 @@ +mockConsoleOutput = false; @@ -84,11 +83,9 @@ test('database data is separated', function () { }); test('cache data is separated', function () { - CacheManager::$addTags = true; - config([ 'tenancy.bootstrappers' => [ - PrefixCacheTenancyBootstrapper::class, + CacheTagBootstrapper::class, ], 'cache.default' => 'redis', ]); diff --git a/tests/CacheManagerTest.php b/tests/CacheManagerTest.php index 7b1b99da..ff8a853b 100644 --- a/tests/CacheManagerTest.php +++ b/tests/CacheManagerTest.php @@ -2,16 +2,15 @@ declare(strict_types=1); -use Stancl\Tenancy\CacheManager; use Stancl\Tenancy\Tests\Etc\Tenant; use Illuminate\Support\Facades\Event; use Stancl\Tenancy\Events\TenancyInitialized; use Stancl\Tenancy\Listeners\BootstrapTenancy; +use Stancl\Tenancy\Bootstrappers\CacheTagBootstrapper; beforeEach(function () { - config(['tenancy.bootstrappers' => []]); + config(['tenancy.bootstrappers' => [CacheTagBootstrapper::class]]); - CacheManager::$addTags = true; Event::listen(TenancyInitialized::class, BootstrapTenancy::class); }); diff --git a/tests/GlobalCacheTest.php b/tests/GlobalCacheTest.php index c4fcb0e5..f59ea401 100644 --- a/tests/GlobalCacheTest.php +++ b/tests/GlobalCacheTest.php @@ -2,16 +2,17 @@ declare(strict_types=1); +use Stancl\Tenancy\Tests\Etc\Tenant; use Illuminate\Support\Facades\Event; use Stancl\Tenancy\Events\TenancyEnded; -use Stancl\Tenancy\Events\TenancyInitialized; use Stancl\Tenancy\Facades\GlobalCache; +use Stancl\Tenancy\Events\TenancyInitialized; use Stancl\Tenancy\Listeners\BootstrapTenancy; use Stancl\Tenancy\Listeners\RevertToCentralContext; -use Stancl\Tenancy\Tests\Etc\Tenant; +use Stancl\Tenancy\Bootstrappers\CacheTagBootstrapper; beforeEach(function () { - config(['tenancy.bootstrappers' => []]); + config(['tenancy.bootstrappers' => [CacheTagBootstrapper::class]]); Event::listen(TenancyInitialized::class, BootstrapTenancy::class); Event::listen(TenancyEnded::class, RevertToCentralContext::class);