mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 17:44:04 +00:00
Update defaulting test
This commit is contained in:
parent
f12f119ff2
commit
835b169d60
1 changed files with 5 additions and 8 deletions
|
|
@ -363,25 +363,22 @@ test('cache store prefix generation can be customized', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('stores get prefixed using the default way if no prefix generator is specified', function() {
|
test('stores get prefixed using the default way if no prefix generator is specified', function() {
|
||||||
// Make 'redis2' the default cache driver
|
|
||||||
config(['cache.default' => 'redis2']);
|
|
||||||
$originalPrefix = config('cache.prefix');
|
$originalPrefix = config('cache.prefix');
|
||||||
$prefixBase = config('tenancy.cache.prefix_base');
|
$prefixBase = config('tenancy.cache.prefix_base');
|
||||||
|
|
||||||
$tenant = Tenant::create();
|
$tenant = Tenant::create();
|
||||||
$defaultPrefix = $originalPrefix . $prefixBase . $tenant->getTenantKey();
|
$defaultPrefix = $originalPrefix . $prefixBase . $tenant->getTenantKey();
|
||||||
|
|
||||||
|
// Don't specify a prefix generator
|
||||||
|
// Let the prefix get created using the default approach
|
||||||
PrefixCacheTenancyBootstrapper::$tenantCacheStores = ['redis', 'redis2'];
|
PrefixCacheTenancyBootstrapper::$tenantCacheStores = ['redis', 'redis2'];
|
||||||
|
|
||||||
// Don't add a generator for 'redis2'
|
|
||||||
// Let the prefix get created using the default approach
|
|
||||||
tenancy()->initialize($tenant);
|
tenancy()->initialize($tenant);
|
||||||
|
|
||||||
// Other stores without a prefix generator use the default generator too
|
// Other stores without a prefix generator use the default generator too
|
||||||
expect($defaultPrefix . ':')
|
expect($defaultPrefix . ':')
|
||||||
->toBe(cache()->getPrefix())
|
->toBe(app(PrefixCacheTenancyBootstrapper::class)->generatePrefix($tenant) . ':')
|
||||||
->toBe(app('cache')->getPrefix())
|
->toBe(cache()->getPrefix()) // Get prefix of the default store ('redis')
|
||||||
->toBe(app('cache.store')->getPrefix());
|
->toBe(cache()->store('redis2')->getPrefix());
|
||||||
|
|
||||||
tenancy()->end();
|
tenancy()->end();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue