diff --git a/tests/CacheManagerTest.php b/tests/CacheManagerTest.php index 938699d2..b8ce09f9 100644 --- a/tests/CacheManagerTest.php +++ b/tests/CacheManagerTest.php @@ -88,4 +88,21 @@ class CacheManagerTest extends TestCase tenancy()->init('foo.localhost'); $this->assertSame('bar', cache('foo')); } + + /** @test */ + public function cache_is_persisted_when_reidentification_is_used() + { + tenant()->create('foo.localhost'); + tenant()->create('bar.localhost'); + tenancy()->init('foo.localhost'); + + cache(['foo' => 'bar'], 10); + $this->assertSame('bar', cache('foo')); + + tenancy()->init('bar.localhost'); + tenancy()->end(); + + tenancy()->init('foo.localhost'); + $this->assertSame('bar', cache('foo')); + } } diff --git a/tests/GlobalCacheTest.php b/tests/GlobalCacheTest.php index e67a0c73..bdbcedfe 100644 --- a/tests/GlobalCacheTest.php +++ b/tests/GlobalCacheTest.php @@ -21,7 +21,7 @@ class GlobalCacheTest extends TestCase $this->assertSame('bar', GlobalCache::get('foo')); GlobalCache::put(['abc' => 'xyz'], 1); - cache(['def' => 'ghi'], 1); + cache(['def' => 'ghi'], 10); $this->assertSame('ghi', cache('def')); tenancy()->end(); diff --git a/tests/TestCase.php b/tests/TestCase.php index b9b9c20b..200c70b0 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -19,6 +19,7 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase parent::setUp(); Redis::connection('tenancy')->flushdb(); + Redis::connection('cache')->flushdb(); if ($this->autoCreateTenant) { $this->createTenant(); @@ -77,6 +78,7 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase 's3', ], 'tenancy.redis.tenancy' => true, + 'tenancy.redis.prefixed_connections' => ['default'], 'tenancy.migrations_directory' => database_path('../migrations'), ]); }