mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 08:04:03 +00:00
Add support for global cache (#78)
This commit is contained in:
parent
d0d1f6930b
commit
92ebc1f01b
5 changed files with 65 additions and 2 deletions
43
tests/GlobalCacheTest.php
Normal file
43
tests/GlobalCacheTest.php
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace Stancl\Tenancy\Tests;
|
||||
|
||||
use GlobalCache;
|
||||
|
||||
class GlobalCacheTest extends TestCase
|
||||
{
|
||||
public $autoCreateTenant = false;
|
||||
public $autoInitTenancy = false;
|
||||
|
||||
/** @test */
|
||||
public function global_cache_manager_stores_data_in_global_cache()
|
||||
{
|
||||
$this->assertSame(null, cache('foo'));
|
||||
GlobalCache::put(['foo' => 'bar'], 1);
|
||||
$this->assertSame('bar', GlobalCache::get('foo'));
|
||||
|
||||
tenant()->create('foo.localhost');
|
||||
tenancy()->init('foo.localhost');
|
||||
$this->assertSame('bar', GlobalCache::get('foo'));
|
||||
|
||||
GlobalCache::put(['abc' => 'xyz'], 1);
|
||||
cache(['def' => 'ghi'], 1);
|
||||
$this->assertSame('ghi', cache('def'));
|
||||
|
||||
tenancy()->end();
|
||||
$this->assertSame('xyz', GlobalCache::get('abc'));
|
||||
$this->assertSame('bar', GlobalCache::get('foo'));
|
||||
$this->assertSame(null, cache('def'));
|
||||
|
||||
tenant()->create('bar.localhost');
|
||||
tenancy()->init('bar.localhost');
|
||||
$this->assertSame('xyz', GlobalCache::get('abc'));
|
||||
$this->assertSame('bar', GlobalCache::get('foo'));
|
||||
$this->assertSame(null, cache('def'));
|
||||
cache(['def' => 'xxx'], 1);
|
||||
$this->assertSame('xxx', cache('def'));
|
||||
|
||||
tenancy()->init('foo.localhost');
|
||||
$this->assertSame('ghi', cache('def'));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue