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

Override cache manager only in CacheTagsBootstrapper

This commit is contained in:
lukinovec 2023-04-19 09:37:10 +02:00
parent 1d52096d6e
commit 2171ca9c68
7 changed files with 45 additions and 58 deletions

View file

@ -41,7 +41,6 @@ use Stancl\Tenancy\CacheManager;
beforeEach(function () {
$this->mockConsoleOutput = false;
CacheManager::$addTags = false;
config(['cache.default' => $cacheDriver = 'redis']);
PrefixCacheTenancyBootstrapper::$tenantCacheStores = [$cacheDriver];
@ -57,7 +56,6 @@ beforeEach(function () {
});
afterEach(function () {
CacheManager::$addTags = false;
PrefixCacheTenancyBootstrapper::$tenantCacheStores = [];
});

View file

@ -14,7 +14,6 @@ use Stancl\Tenancy\Bootstrappers\CacheTagsBootstrapper;
use Stancl\Tenancy\Bootstrappers\PrefixCacheTenancyBootstrapper;
beforeEach(function () {
CacheManager::$addTags = false;
config(['cache.default' => $cacheDriver = 'redis']);
PrefixCacheTenancyBootstrapper::$tenantCacheStores = [$cacheDriver];

View file

@ -24,8 +24,6 @@ beforeEach(function () {
PrefixCacheTenancyBootstrapper::$tenantCacheStores = [$cacheDriver];
PrefixCacheTenancyBootstrapper::$prefixGenerator = null;
config('tenancy.cache.manager')::$addTags = false;
Event::listen(TenancyInitialized::class, BootstrapTenancy::class);
Event::listen(TenancyEnded::class, RevertToCentralContext::class);
});
@ -35,28 +33,6 @@ afterEach(function () {
PrefixCacheTenancyBootstrapper::$prefixGenerator = null;
});
test('Tenancy overrides CacheManager', function() {
$tenancyCacheManager = config('tenancy.cache.manager');
expect(app('cache')::class)->toBe($tenancyCacheManager);
expect(app(CacheManager::class)::class)->toBe($tenancyCacheManager);
tenancy()->initialize(Tenant::create(['id' => 'first']));
expect(app('cache')::class)->toBe($tenancyCacheManager);
expect(app(CacheManager::class)::class)->toBe($tenancyCacheManager);
tenancy()->initialize(Tenant::create(['id' => 'second']));
expect(app('cache')::class)->toBe($tenancyCacheManager);
expect(app(CacheManager::class)::class)->toBe($tenancyCacheManager);
tenancy()->end();
expect(app('cache')::class)->toBe($tenancyCacheManager);
expect(app(CacheManager::class)::class)->toBe($tenancyCacheManager);
});
test('correct cache prefix is used in all contexts', function () {
$originalPrefix = config('cache.prefix');
$prefixBase = config('tenancy.cache.prefix_base');