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

Tenant::with

This commit is contained in:
Samuel Štancl 2019-09-20 19:44:05 +02:00
parent 61cc0d9364
commit 93fc961b34
2 changed files with 28 additions and 2 deletions

View file

@ -72,4 +72,18 @@ class TenantClassTest extends TestCase
$this->assertEqualsCanonicalizing(['completely.localhost', 'different.localhost', 'domains.localhost'], $tenant->domains);
$this->assertEqualsCanonicalizing(['completely.localhost', 'different.localhost', 'domains.localhost'], tenancy()->find($id)->domains);
}
/** @test */
public function with_methods_work()
{
$id = 'foo' . $this->randomString();
$tenant = Tenant::new()->withDomains(['foo.localhost'])->with('id', $id);
$this->assertSame($id, $tenant->id);
$id2 = 'bar' . $this->randomString();
$tenant2 = Tenant::new()->withDomains(['bar.localhost'])->withId($id2)->withFooBar('xyz');
$this->assertSame($id2, $tenant2->data['id']);
$this->assertSame('xyz', $tenant2->foo_bar);
$this->assertArrayHasKey('foo_bar', $tenant2->data);
}
}