1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 14:54:03 +00:00

Add array support to the storage.

(Existing tests have been modified, but only in a way that makes them more correct than they were, making this a backwards compatible feature.)
This commit is contained in:
Samuel Štancl 2019-02-10 21:09:42 +01:00
parent f9f71ec49f
commit f3e2642fa2
3 changed files with 61 additions and 24 deletions

View file

@ -6,14 +6,7 @@ use Stancl\Tenancy\Interfaces\StorageDriver;
class TenantStorageTest extends TestCase
{
public function setUp()
{
parent::setUp();
// todo find a way to run this for each storage driver (once there are more of them)
$this->storage = app(StorageDriver::class);
}
// todo find a way to run this for each storage driver (once there are more of them)
/** @test */
public function deleting_a_tenant_works()
@ -32,7 +25,7 @@ class TenantStorageTest extends TestCase
{
tenant()->set('foo', 'bar');
$this->assertSame('bar', $this->storage->get(tenant('uuid'), 'foo'));
$this->assertSame('bar', tenant()->get('foo'));
}
/** @test */
@ -40,7 +33,7 @@ class TenantStorageTest extends TestCase
{
tenancy()->put('foo', 'bar');
$this->assertSame('bar', $this->storage->get(tenant('uuid'), 'foo'));
$this->assertSame('bar', tenant()->get('foo'));
}
/** @test */
@ -91,4 +84,26 @@ class TenantStorageTest extends TestCase
$this->assertNotSame($vals, tenancy()->get($keys));
$this->assertFalse(array_intersect($data, tenant()->tenant) == $data); // assert array not subset
}
/** @test */
public function arrays_can_be_stored()
{
tenant()->put('foo', [1, 2]);
$this->assertSame([1, 2], tenant()->get('foo'));
}
/** @test */
public function put_returns_the_value_when_two_arguments_are_used()
{
$this->assertSame('bar', tenant()->put('foo', 'bar'));
}
/** @test */
public function put_returns_the_key_value_pairs_when_a_single_argument_is_used()
{
$value = ['foo' => 'bar', 'abc' => 'xyz'];
$this->assertSame($value, tenancy()->put($value));
}
}