1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 16:14:02 +00:00

Add more TenantManager tests

This commit is contained in:
Samuel Štancl 2019-02-09 00:17:51 +01:00
parent 2c69c37032
commit 8d382024a3
3 changed files with 64 additions and 13 deletions

View file

@ -17,5 +17,53 @@ class TenantManagerTest extends TestCase
$this->assertSame($tenant, tenancy()->tenant);
}
// todo write more tests
/** @test */
public function invoke_works()
{
$this->assertSame(tenant('uuid'), tenant()('uuid'));
}
/** @test */
public function initById_works()
{
$tenant = tenant()->create('foo.localhost');
$this->assertNotSame($tenant, tenancy()->tenant);
tenancy()->initById($tenant['uuid']);
$this->assertSame($tenant, tenancy()->tenant);
}
/** @test */
public function findByDomain_works()
{
$tenant = tenant()->create('foo.localhost');
$this->assertSame($tenant, tenant()->findByDomain('foo.localhost'));
}
/** @test */
public function getIdByDomain_works()
{
$tenant = tenant()->create('foo.localhost');
$this->assertSame(tenant()->getTenantIdByDomain('foo.localhost'), tenant()->getIdByDomain('foo.localhost'));
}
/** @test */
public function findWorks()
{
tenant()->create('dev.localhost');
tenancy()->init('dev.localhost');
$this->assertSame(tenant()->tenant, tenant()->find(tenant('uuid')));
}
/** @test */
public function getTenantByIdWorks()
{
$tenant = tenant()->create('foo.localhost');
$this->assertSame($tenant, tenancy()->getTenantById($tenant['uuid']));
}
}

View file

@ -27,6 +27,14 @@ class TenantStorageTest extends TestCase
$this->assertFalse(tenant()->all()->contains($abc));
}
/** @test */
public function set_is_a_working_alias_for_put()
{
tenant()->set('foo', 'bar');
$this->assertSame('bar', $this->storage->get(tenant('uuid'), 'foo'));
}
/** @test */
public function put_works_with_key_and_value_as_separate_args()
{