1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 09:34:05 +00:00

Fix custom columns & add test

This commit is contained in:
Samuel Štancl 2019-09-04 16:41:07 +02:00
parent 6de9ee9421
commit 8a25cf2010
3 changed files with 55 additions and 1 deletions

View file

@ -170,4 +170,32 @@ class TenantStorageTest extends TestCase
$this->assertSame('bar', tenancy()->get('foo'));
$this->assertSame(['bar'], tenancy()->get(['foo']));
}
/** @test */
public function custom_columns_work_with_db_storage_driver()
{
if (config('tenancy.storage_driver') != 'Stancl\Tenancy\StorageDrivers\DatabaseStorageDriver') {
$this->markTestSkipped();
}
tenancy()->end();
$this->loadMigrationsFrom([
'--path' => __DIR__ . '/Etc',
'--database' => 'central',
]);
config(['database.default' => 'sqlite']); // fix issue caused by loadMigrationsFrom
config(['tenancy.storage.db.custom_columns' => [
'foo'
]]);
tenancy()->create('foo.localhost');
tenancy()->init('foo.localhost');
tenancy()->put(['foo' => 'bar', 'abc' => 'xyz']);
$this->assertSame(['bar', 'xyz'], tenancy()->get(['foo', 'abc']));
$this->assertSame('bar', \DB::connection('central')->table('tenants')->where('uuid', tenant('uuid'))->first()->foo);
}
}