1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 17:44:04 +00:00

Data cache test

This commit is contained in:
Samuel Štancl 2019-09-20 17:56:22 +02:00
parent 0fe2d2de87
commit 9892c3afc7

33
tests/TenantClassTest.php Normal file
View file

@ -0,0 +1,33 @@
<?php
namespace Stancl\Tenancy\Tests;
use Mockery;
use Stancl\Tenancy\Contracts\StorageDriver;
use Stancl\Tenancy\Tenant;
class TenantClassTest extends TestCase
{
public $autoInitTenancy = false;
public $autoCreateTenant = false;
/** @test */
public function data_cache_works_properly()
{
$spy = Mockery::spy(config('tenancy.storage_driver'))->makePartial();
$this->instance(StorageDriver::class, $spy);
$tenant = Tenant::create(['foo.localhost'], ['foo' => 'bar']);
$this->assertSame('bar', $tenant->data['foo']);
$tenant->put('abc', 'xyz');
$this->assertSame('xyz', $tenant->data['abc']);
$tenant->put(['aaa' => 'bbb', 'ccc' => 'ddd']);
$this->assertSame('bbb', $tenant->data['aaa']);
$this->assertSame('ddd', $tenant->data['ccc']);
$spy->shouldNotHaveReceived('get');
Mockery::close();
}
}