mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 16:44:04 +00:00
Reset adjustCacheManagerUsing in revert() and TestCase
This commit is contained in:
parent
b7df2ca436
commit
6a8358fd80
2 changed files with 10 additions and 0 deletions
|
|
@ -52,6 +52,8 @@ class DatabaseCacheBootstrapper implements TenancyBootstrapper
|
|||
$this->originalConnections[$storeName] = $this->config->get("cache.stores.{$storeName}.connection");
|
||||
$this->originalLockConnections[$storeName] = $this->config->get("cache.stores.{$storeName}.lock_connection");
|
||||
|
||||
// todo0 does this handle *already resolved* stores?
|
||||
|
||||
$this->config->set("cache.stores.{$storeName}.connection", 'tenant');
|
||||
$this->config->set("cache.stores.{$storeName}.lock_connection", 'tenant');
|
||||
|
||||
|
|
@ -64,10 +66,12 @@ class DatabaseCacheBootstrapper implements TenancyBootstrapper
|
|||
// (this is our only use of $adjustCacheManagerUsing anyway) but ideally at some point we'd have a better solution.
|
||||
TenancyServiceProvider::$adjustCacheManagerUsing = function (CacheManager $manager) use ($stores) {
|
||||
foreach ($stores as $storeName) {
|
||||
// @phpstan-ignore-next-line method.notFound
|
||||
$manager->store($storeName)->getStore()->setConnection(
|
||||
DB::connection($this->originalConnections[$storeName] ?? config('tenancy.database.central_connection'))
|
||||
);
|
||||
|
||||
// @phpstan-ignore-next-line method.notFound
|
||||
$manager->store($storeName)->getStore()->setLockConnection(
|
||||
DB::connection($this->originalLockConnections[$storeName] ?? config('tenancy.database.central_connection'))
|
||||
);
|
||||
|
|
@ -83,6 +87,8 @@ class DatabaseCacheBootstrapper implements TenancyBootstrapper
|
|||
|
||||
$this->cache->purge($storeName);
|
||||
}
|
||||
|
||||
TenancyServiceProvider::$adjustCacheManagerUsing = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -39,6 +39,10 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
|
|||
|
||||
ini_set('memory_limit', '1G');
|
||||
|
||||
TenancyServiceProvider::$configure = null;
|
||||
TenancyServiceProvider::$registerForgetTenantParameterListener = true;
|
||||
TenancyServiceProvider::$adjustCacheManagerUsing = null;
|
||||
|
||||
Redis::connection('default')->flushdb();
|
||||
Redis::connection('cache')->flushdb();
|
||||
Artisan::call('cache:clear memcached'); // flush memcached
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue