1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 22:34:03 +00:00
This commit is contained in:
Samuel Štancl 2019-09-16 18:09:09 +02:00
parent 50a77ee826
commit a9c37d1535
8 changed files with 24 additions and 25 deletions

View file

@ -11,11 +11,11 @@ class DatabaseManagerTest extends TestCase
public $autoInitTenancy = false;
/** @test */
public function disconnect_method_works()
public function reconnect_method_works()
{
$old_connection_name = app(\Illuminate\Database\DatabaseManager::class)->connection()->getName();
tenancy()->init();
tenancy()->disconnectDatabase();
tenancy()->init('test.localhost');
app(\Stancl\Tenancy\DatabaseManager::class)->reconnect();
$new_connection_name = app(\Illuminate\Database\DatabaseManager::class)->connection()->getName();
$this->assertSame($old_connection_name, $new_connection_name);

View file

@ -22,7 +22,7 @@ class ReidentificationTest extends TestCase
$originals[$disk] = config("filesystems.disks.{$disk}.root");
}
tenancy()->init('localhost');
tenancy()->init('test.localhost');
Tenant::new()->withDomains(['second.localhost'])->save();
tenancy()->init('second.localhost');
@ -49,7 +49,7 @@ class ReidentificationTest extends TestCase
{
$original = storage_path();
tenancy()->init('localhost');
tenancy()->init('test.localhost');
Tenant::new()->withDomains(['second.localhost'])->save();
tenancy()->init('second.localhost');

View file

@ -14,7 +14,7 @@ class TenantManagerEventsTest extends TestCase
{
$id = Tenant::new()->withDomains(['foo.localhost'])->save()['id'];
Tenancy::bootstrapping(function ($tenantManager) use ($id) {
Tenancy::eventListener('bootstrapping', function ($tenantManager) use ($id) {
if ($tenantManager->tenant['id'] === $id) {
config(['tenancy.foo' => 'bar']);
}
@ -30,7 +30,7 @@ class TenantManagerEventsTest extends TestCase
{
$id = Tenant::new()->withDomains(['foo.localhost'])->save()['id'];
Tenancy::bootstrapped(function ($tenantManager) use ($id) {
Tenancy::eventListener('bootstrapped', function ($tenantManager) use ($id) {
if ($tenantManager->tenant['id'] === $id) {
config(['tenancy.foo' => 'bar']);
}
@ -46,7 +46,7 @@ class TenantManagerEventsTest extends TestCase
{
$id = Tenant::new()->withDomains(['foo.localhost'])->save()['id'];
Tenancy::ending(function ($tenantManager) use ($id) {
Tenancy::eventListener('ending', function ($tenantManager) use ($id) {
if ($tenantManager->tenant['id'] === $id) {
config(['tenancy.foo' => 'bar']);
}
@ -64,7 +64,7 @@ class TenantManagerEventsTest extends TestCase
{
$id = Tenant::new()->withDomains(['foo.localhost'])->save()['id'];
Tenancy::ended(function ($tenantManager) use ($id) {
Tenancy::eventListener('ended', function ($tenantManager) use ($id) {
if ($tenantManager->tenant['id'] === $id) {
config(['tenancy.foo' => 'bar']);
}
@ -102,7 +102,7 @@ class TenantManagerEventsTest extends TestCase
$id = Tenant::create('abc.localhost')['id'];
Tenancy::bootstrapping(function ($tenancy) use ($id) {
Tenancy::eventListener('bootstrapping', function ($tenancy) use ($id) {
if ($tenancy->tenant['id'] === $id) {
$tenancy->database->useConnection('tenantabc');
@ -125,7 +125,7 @@ class TenantManagerEventsTest extends TestCase
$id = Tenant::create('abc.localhost')['id'];
Tenancy::bootstrapping(function ($tenancy) use ($id) {
Tenancy::eventListener('bootstrapping', function ($tenancy) use ($id) {
if ($tenancy->tenant['id'] === $id) {
$tenancy->database->useConnection('tenantabc');
// return ['database'];

View file

@ -14,13 +14,13 @@ class TenantManagerTest extends TestCase
public $autoInitTenancy = false;
/** @test */
public function current_tenant_is_stored_in_the_tenant_property()
public function current_tenant_can_be_retrieved_using_getTenant()
{
$tenant = Tenant::new()->withDomains(['localhost'])->save();
tenancy()->init('localhost');
tenancy()->init('test.localhost');
$this->assertSame($tenant, tenancy()->tenant);
$this->assertSame($tenant, tenancy()->getTenant());
}
/** @test */