From 7ea6d24b89b06d247fd69538609c58bec73e0386 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Sat, 19 Oct 2019 23:51:46 +0200 Subject: [PATCH] Regression test w/ markTestIncomplete() --- src/DatabaseManager.php | 2 +- tests/DatabaseManagerTest.php | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/DatabaseManager.php b/src/DatabaseManager.php index 6d580c1a..3a42d3b0 100644 --- a/src/DatabaseManager.php +++ b/src/DatabaseManager.php @@ -52,8 +52,8 @@ class DatabaseManager { // Opposite order to connect() because we don't // want to ever purge the central connection - $this->switchConnection($this->originalDefaultConnectionName); $this->setDefaultConnection($this->originalDefaultConnectionName); + $this->switchConnection($this->originalDefaultConnectionName); } /** diff --git a/tests/DatabaseManagerTest.php b/tests/DatabaseManagerTest.php index cbd976e8..10ba4ddd 100644 --- a/tests/DatabaseManagerTest.php +++ b/tests/DatabaseManagerTest.php @@ -45,4 +45,21 @@ class DatabaseManagerTest extends TestCase $this->assertSame('tenant', config('database.default')); $this->assertSame('bar', config('database.connections.' . config('database.default') . '.foo')); } + + /** @test */ + public function ending_tenancy_doesnt_purge_the_central_connection() + { + $this->markTestIncomplete('Seems like this only happens on MySQL?'); + + // regression test for https://github.com/stancl/tenancy/pull/189 + // config(['tenancy.migrate_after_creation' => true]); + + tenancy()->create(['foo.localhost']); + tenancy()->init('foo.localhost'); + tenancy()->end(); + + $this->assertNotEmpty(tenancy()->all()); + + tenancy()->all()->each->delete(); + } }