mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 18:54:03 +00:00
Fix DB storage driver bug, add regression test (tenant_data_can_be_set_during_creation)
This commit is contained in:
parent
85eaefef48
commit
c81218a993
2 changed files with 12 additions and 1 deletions
|
|
@ -80,7 +80,7 @@ class DatabaseStorageDriver implements StorageDriver
|
||||||
public function createTenant(Tenant $tenant): void
|
public function createTenant(Tenant $tenant): void
|
||||||
{
|
{
|
||||||
$this->centralDatabase->transaction(function () use ($tenant) {
|
$this->centralDatabase->transaction(function () use ($tenant) {
|
||||||
Tenants::create(['id' => $tenant->id, 'data' => '{}'])->toArray();
|
Tenants::create(['id' => $tenant->id, 'data' => json_encode($tenant->data)])->toArray();
|
||||||
|
|
||||||
$domainData = [];
|
$domainData = [];
|
||||||
foreach ($tenant->domains as $domain) {
|
foreach ($tenant->domains as $domain) {
|
||||||
|
|
|
||||||
|
|
@ -94,4 +94,15 @@ class TenantClassTest extends TestCase
|
||||||
$this->expectException(\BadMethodCallException::class);
|
$this->expectException(\BadMethodCallException::class);
|
||||||
$tenant->sdjigndfgnjdfgj();
|
$tenant->sdjigndfgnjdfgj();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @test */
|
||||||
|
public function tenant_data_can_be_set_during_creation()
|
||||||
|
{
|
||||||
|
Tenant::new()->withData(['foo' => 'bar'])->save();
|
||||||
|
|
||||||
|
$data = tenancy()->all()->first()->data;
|
||||||
|
unset($data['id']);
|
||||||
|
|
||||||
|
$this->assertSame(['foo' => 'bar'], $data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue