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

Null connection test

This commit is contained in:
Samuel Štancl 2019-09-20 16:57:53 +02:00
parent 2f6f0e4d50
commit 65b2c6ceee
2 changed files with 17 additions and 1 deletions

View file

@ -10,7 +10,7 @@ return [
'custom_columns' => [
// 'plan',
],
'connection' => null, // todo verify this works
'connection' => null,
'table_names' => [
'TenantModel' => 'tenants',
'DomainModel' => 'domains',

View file

@ -77,4 +77,20 @@ class TenancyBootstrappersTest extends TestCase
$expected = [config('tenancy.cache.tag_base') . tenant('id'), 'foo', 'bar'];
$this->assertEquals($expected, cache()->tags(['foo', 'bar'])->getTags()->getNames());
}
/** @test */
public function the_default_db_connection_is_used_when_the_config_value_is_null()
{
$original = config('database.default');
tenancy()->create(['foo.localhost']);
tenancy()->init('foo.localhost');
$this->assertSame(null, config("database.connections.$original.foo"));
config(["database.connections.$original.foo" => 'bar']);
tenancy()->create(['bar.localhost']);
tenancy()->init('bar.localhost');
$this->assertSame('bar', config("database.connections.$original.foo"));
}
}