From abda76a0f5ad2e4999d9deab55371a47c3993290 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Wed, 14 Aug 2019 17:07:58 +0200 Subject: [PATCH] end() events --- tests/TenantManagerTest.php | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/TenantManagerTest.php b/tests/TenantManagerTest.php index e05c4ef2..faa2da3d 100644 --- a/tests/TenantManagerTest.php +++ b/tests/TenantManagerTest.php @@ -254,6 +254,7 @@ class TenantManagerTest extends TestCase } }); + $this->assertSame(null, config('tenancy.foo')); tenancy()->init('foo.localhost'); $this->assertSame('bar', config('tenancy.foo')); } @@ -269,7 +270,44 @@ class TenantManagerTest extends TestCase } }); + $this->assertSame(null, config('tenancy.foo')); tenancy()->init('foo.localhost'); $this->assertSame('bar', config('tenancy.foo')); } + + /** @test */ + public function ending_event_works() + { + $uuid = tenant()->create('foo.localhost')['uuid']; + + Tenancy::ending(function ($tenantManager) use ($uuid) { + if ($tenantManager->tenant['uuid'] === $uuid) { + config(['tenancy.foo' => 'bar']); + } + }); + + $this->assertSame(null, config('tenancy.foo')); + tenancy()->init('foo.localhost'); + $this->assertSame(null, config('tenancy.foo')); + tenancy()->end(); + $this->assertSame('bar', config('tenancy.foo')); + } + + /** @test */ + public function ended_event_works() + { + $uuid = tenant()->create('foo.localhost')['uuid']; + + Tenancy::ended(function ($tenantManager) use ($uuid) { + if ($tenantManager->tenant['uuid'] === $uuid) { + config(['tenancy.foo' => 'bar']); + } + }); + + $this->assertSame(null, config('tenancy.foo')); + tenancy()->init('foo.localhost'); + $this->assertSame(null, config('tenancy.foo')); + tenancy()->end(); + $this->assertSame('bar', config('tenancy.foo')); + } }