From acbdb4bbca97a674b6d43cfdf92312961ff60c2a Mon Sep 17 00:00:00 2001 From: Abrar Ahmad Date: Thu, 30 Jun 2022 17:06:35 +0500 Subject: [PATCH] Update AutomaticModeTest.php --- tests/AutomaticModeTest.php | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/tests/AutomaticModeTest.php b/tests/AutomaticModeTest.php index f83a797a..cb4c5536 100644 --- a/tests/AutomaticModeTest.php +++ b/tests/AutomaticModeTest.php @@ -15,7 +15,8 @@ beforeEach(function () { Event::listen(TenancyEnded::class, RevertToCentralContext::class); }); -test('context is switched when tenancy is initialized', function () { +function contextISSwitchedWhenTenancyInitialized() +{ config(['tenancy.bootstrappers' => [ MyBootstrapper::class, ]]); @@ -27,20 +28,14 @@ test('context is switched when tenancy is initialized', function () { tenancy()->initialize($tenant); expect(app('tenancy_initialized_for_tenant'))->toBe('acme'); +} + +test('context is switched when tenancy is initialized', function () { + contextISSwitchedWhenTenancyInitialized(); }); test('context is reverted when tenancy is ended', function () { - config(['tenancy.bootstrappers' => [ - MyBootstrapper::class, - ]]); - - $tenant = Tenant::create([ - 'id' => 'acme', - ]); - - tenancy()->initialize($tenant); - - expect(app('tenancy_initialized_for_tenant'))->toBe('acme'); + contextISSwitchedWhenTenancyInitialized(); tenancy()->end();