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

Multiple domains test

This commit is contained in:
Samuel Štancl 2019-09-20 18:13:25 +02:00
parent bdaf6cf824
commit b268dd5d50
2 changed files with 11 additions and 1 deletions

View file

@ -16,7 +16,7 @@ class CreateDomainsTable extends Migration
public function up() public function up()
{ {
Schema::create('domains', function (Blueprint $table) { Schema::create('domains', function (Blueprint $table) {
$table->string('tenant_id', 36)->primary(); // 36 characters is the default uuid length $table->string('tenant_id', 36); // 36 characters is the default uuid length // todo foreign key?
$table->string('domain', 255)->index(); // don't change this $table->string('domain', 255)->index(); // don't change this
}); });
} }

View file

@ -7,6 +7,7 @@ namespace Stancl\Tenancy\Tests;
use Mockery; use Mockery;
use Stancl\Tenancy\Contracts\StorageDriver; use Stancl\Tenancy\Contracts\StorageDriver;
use Stancl\Tenancy\Tenant; use Stancl\Tenancy\Tenant;
use Tenancy;
class TenantClassTest extends TestCase class TenantClassTest extends TestCase
{ {
@ -36,4 +37,13 @@ class TenantClassTest extends TestCase
Mockery::close(); Mockery::close();
} }
/** @test */
public function tenant_can_have_multiple_domains()
{
$tenant = Tenant::create(['foo.localhost', 'bar.localhost']);
$this->assertSame(['foo.localhost', 'bar.localhost'], $tenant->domains);
$this->assertSame($tenant->id, Tenancy::findByDomain('foo.localhost')->id);
$this->assertSame($tenant->id, Tenancy::findByDomain('bar.localhost')->id);
}
} }