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

Add one more test for prevents

This commit is contained in:
Samuel Štancl 2019-08-14 22:18:18 +02:00
parent 4aa35322da
commit 9c269b087e

View file

@ -111,4 +111,26 @@ class TenantManagerEventsTest extends TestCase
tenancy()->init('abc.localhost'); tenancy()->init('abc.localhost');
$this->assertSame('tenantabc', \DB::connection()->getConfig()['name']); $this->assertSame('tenantabc', \DB::connection()->getConfig()['name']);
} }
/** @test */
public function database_cannot_be_reconnected_without_using_prevents()
{
config(['database.connections.tenantabc' => [
'driver' => 'sqlite',
'database' => database_path('some_special_database.sqlite'),
]]);
$uuid = Tenant::create('abc.localhost')['uuid'];
Tenancy::bootstrapping(function ($tenancy) use ($uuid) {
if ($tenancy->tenant['uuid'] === $uuid) {
$tenancy->database->useConnection('tenantabc');
// return ['database'];
}
});
$this->assertNotSame('tenantabc', \DB::connection()->getConfig()['name']);
tenancy()->init('abc.localhost');
$this->assertSame('tenant', \DB::connection()->getConfig()['name']);
}
} }