mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 21:54:03 +00:00
Small testing improvements
This commit is contained in:
parent
3481e24c7d
commit
0c1912b9c5
2 changed files with 14 additions and 17 deletions
|
|
@ -42,6 +42,7 @@ use Stancl\Tenancy\CacheManager;
|
|||
beforeEach(function () {
|
||||
$this->mockConsoleOutput = false;
|
||||
CacheManager::$addTags = false;
|
||||
PrefixCacheTenancyBootstrapper::$tenantCacheStores = ['redis'];
|
||||
|
||||
Event::listen(
|
||||
TenantCreated::class,
|
||||
|
|
@ -54,6 +55,11 @@ beforeEach(function () {
|
|||
Event::listen(TenancyEnded::class, RevertToCentralContext::class);
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
CacheManager::$addTags = false;
|
||||
PrefixCacheTenancyBootstrapper::$tenantCacheStores = [];
|
||||
});
|
||||
|
||||
test('database data is separated', function () {
|
||||
config(['tenancy.bootstrappers' => [
|
||||
DatabaseTenancyBootstrapper::class,
|
||||
|
|
@ -86,15 +92,9 @@ test('database data is separated', function () {
|
|||
});
|
||||
|
||||
test('cache data is separated', function (string $bootstrapper) {
|
||||
$cacheDriver = 'redis';
|
||||
|
||||
if ($bootstrapper === PrefixCacheTenancyBootstrapper::class) {
|
||||
PrefixCacheTenancyBootstrapper::$tenantCacheStores = [$cacheDriver];
|
||||
}
|
||||
|
||||
config([
|
||||
'tenancy.bootstrappers' => [$bootstrapper],
|
||||
'cache.default' => $cacheDriver,
|
||||
'cache.default' => 'redis',
|
||||
]);
|
||||
|
||||
$tenant1 = Tenant::create();
|
||||
|
|
@ -128,13 +128,10 @@ test('cache data is separated', function (string $bootstrapper) {
|
|||
|
||||
// Asset central is still the same
|
||||
expect(Cache::get('foo'))->toBe('central');
|
||||
|
||||
// Reset the static property
|
||||
CacheManager::$addTags = false;
|
||||
})->with([
|
||||
'tagging' => CacheTagsBootstrapper::class,
|
||||
'prefixing' => PrefixCacheTenancyBootstrapper::class,
|
||||
])->group('bootstrapper');
|
||||
CacheTagsBootstrapper::class,
|
||||
PrefixCacheTenancyBootstrapper::class,
|
||||
]);
|
||||
|
||||
test('redis data is separated', function () {
|
||||
config(['tenancy.bootstrappers' => [
|
||||
|
|
|
|||
|
|
@ -53,8 +53,8 @@ test('global cache manager stores data in global cache', function (string $boots
|
|||
tenancy()->initialize($tenant1);
|
||||
expect(cache('def'))->toBe('ghi');
|
||||
})->with([
|
||||
'tagging' => CacheTagsBootstrapper::class,
|
||||
'prefixing' => PrefixCacheTenancyBootstrapper::class,
|
||||
CacheTagsBootstrapper::class,
|
||||
PrefixCacheTenancyBootstrapper::class,
|
||||
]);
|
||||
|
||||
test('the global_cache helper supports the same syntax as the cache helper', function (string $bootstrapper) {
|
||||
|
|
@ -73,6 +73,6 @@ test('the global_cache helper supports the same syntax as the cache helper', fun
|
|||
|
||||
expect(cache('foo'))->toBe(null); // tenant cache is not affected
|
||||
})->with([
|
||||
'tagging' => CacheTagsBootstrapper::class,
|
||||
'prefixing' => PrefixCacheTenancyBootstrapper::class,
|
||||
CacheTagsBootstrapper::class,
|
||||
PrefixCacheTenancyBootstrapper::class,
|
||||
]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue