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

ensureTenantCanBeCreated test

This commit is contained in:
Samuel Štancl 2019-09-20 17:05:19 +02:00
parent 65b2c6ceee
commit 8beaaaeda7
2 changed files with 16 additions and 2 deletions

View file

@ -6,6 +6,8 @@ namespace Stancl\Tenancy\Tests;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
use Stancl\Tenancy\Exceptions\DomainsOccupiedByOtherTenantException;
use Stancl\Tenancy\Exceptions\TenantWithThisIdAlreadyExistsException;
use Stancl\Tenancy\Tenant;
use Stancl\Tenancy\TenantManager;
@ -230,4 +232,16 @@ class TenantManagerTest extends TestCase
tenancy()->initialize($tenant2);
$this->assertTrue(\Schema::hasTable('users'));
}
/** @test */
public function ensureTenantCanBeCreated_works()
{
$id = 'foo' . $this->randomString();
Tenant::create(['foo.localhost'], ['id' => $id]);
$this->expectException(DomainsOccupiedByOtherTenantException::class);
Tenant::create(['foo.localhost']);
$this->expectException(TenantWithThisIdAlreadyExistsException::class);
Tenant::create(['bar.localhost'], ['id' => $id]);
}
}