mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 16:14:02 +00:00
Add one more test for prevents
This commit is contained in:
parent
4aa35322da
commit
9c269b087e
1 changed files with 22 additions and 0 deletions
|
|
@ -111,4 +111,26 @@ class TenantManagerEventsTest extends TestCase
|
|||
tenancy()->init('abc.localhost');
|
||||
$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']);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue