mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 17:44:04 +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 () {
|
beforeEach(function () {
|
||||||
$this->mockConsoleOutput = false;
|
$this->mockConsoleOutput = false;
|
||||||
CacheManager::$addTags = false;
|
CacheManager::$addTags = false;
|
||||||
|
PrefixCacheTenancyBootstrapper::$tenantCacheStores = ['redis'];
|
||||||
|
|
||||||
Event::listen(
|
Event::listen(
|
||||||
TenantCreated::class,
|
TenantCreated::class,
|
||||||
|
|
@ -54,6 +55,11 @@ beforeEach(function () {
|
||||||
Event::listen(TenancyEnded::class, RevertToCentralContext::class);
|
Event::listen(TenancyEnded::class, RevertToCentralContext::class);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
afterEach(function () {
|
||||||
|
CacheManager::$addTags = false;
|
||||||
|
PrefixCacheTenancyBootstrapper::$tenantCacheStores = [];
|
||||||
|
});
|
||||||
|
|
||||||
test('database data is separated', function () {
|
test('database data is separated', function () {
|
||||||
config(['tenancy.bootstrappers' => [
|
config(['tenancy.bootstrappers' => [
|
||||||
DatabaseTenancyBootstrapper::class,
|
DatabaseTenancyBootstrapper::class,
|
||||||
|
|
@ -86,15 +92,9 @@ test('database data is separated', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('cache data is separated', function (string $bootstrapper) {
|
test('cache data is separated', function (string $bootstrapper) {
|
||||||
$cacheDriver = 'redis';
|
|
||||||
|
|
||||||
if ($bootstrapper === PrefixCacheTenancyBootstrapper::class) {
|
|
||||||
PrefixCacheTenancyBootstrapper::$tenantCacheStores = [$cacheDriver];
|
|
||||||
}
|
|
||||||
|
|
||||||
config([
|
config([
|
||||||
'tenancy.bootstrappers' => [$bootstrapper],
|
'tenancy.bootstrappers' => [$bootstrapper],
|
||||||
'cache.default' => $cacheDriver,
|
'cache.default' => 'redis',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$tenant1 = Tenant::create();
|
$tenant1 = Tenant::create();
|
||||||
|
|
@ -128,13 +128,10 @@ test('cache data is separated', function (string $bootstrapper) {
|
||||||
|
|
||||||
// Asset central is still the same
|
// Asset central is still the same
|
||||||
expect(Cache::get('foo'))->toBe('central');
|
expect(Cache::get('foo'))->toBe('central');
|
||||||
|
|
||||||
// Reset the static property
|
|
||||||
CacheManager::$addTags = false;
|
|
||||||
})->with([
|
})->with([
|
||||||
'tagging' => CacheTagsBootstrapper::class,
|
CacheTagsBootstrapper::class,
|
||||||
'prefixing' => PrefixCacheTenancyBootstrapper::class,
|
PrefixCacheTenancyBootstrapper::class,
|
||||||
])->group('bootstrapper');
|
]);
|
||||||
|
|
||||||
test('redis data is separated', function () {
|
test('redis data is separated', function () {
|
||||||
config(['tenancy.bootstrappers' => [
|
config(['tenancy.bootstrappers' => [
|
||||||
|
|
|
||||||
|
|
@ -53,8 +53,8 @@ test('global cache manager stores data in global cache', function (string $boots
|
||||||
tenancy()->initialize($tenant1);
|
tenancy()->initialize($tenant1);
|
||||||
expect(cache('def'))->toBe('ghi');
|
expect(cache('def'))->toBe('ghi');
|
||||||
})->with([
|
})->with([
|
||||||
'tagging' => CacheTagsBootstrapper::class,
|
CacheTagsBootstrapper::class,
|
||||||
'prefixing' => PrefixCacheTenancyBootstrapper::class,
|
PrefixCacheTenancyBootstrapper::class,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
test('the global_cache helper supports the same syntax as the cache helper', function (string $bootstrapper) {
|
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
|
expect(cache('foo'))->toBe(null); // tenant cache is not affected
|
||||||
})->with([
|
})->with([
|
||||||
'tagging' => CacheTagsBootstrapper::class,
|
CacheTagsBootstrapper::class,
|
||||||
'prefixing' => PrefixCacheTenancyBootstrapper::class,
|
PrefixCacheTenancyBootstrapper::class,
|
||||||
]);
|
]);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue