From ab009d367952b1a301faed18979fbe3d49a19377 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Tue, 13 Dec 2022 12:39:11 +0100 Subject: [PATCH] Add bootstrapper test --- tests/BootstrapperTest.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/BootstrapperTest.php b/tests/BootstrapperTest.php index d3f2daed..0cab77a3 100644 --- a/tests/BootstrapperTest.php +++ b/tests/BootstrapperTest.php @@ -343,6 +343,22 @@ test('BroadcastTenancyBootstrapper binds TenancyBroadcastManager to BroadcastMan expect(app(BroadcastManager::class))->toBeInstanceOf(BroadcastManager::class); }); +test('bound broadcaster instance is the same before initializing tenancy and after ending it', function() { + config(['broadcasting.default' => 'null']); + TenancyBroadcastManager::$tenantBroadcasters[] = 'null'; + + $originalBroadcaster = app(BroadcasterContract::class); + + tenancy()->initialize(Tenant::create()); + + // TenancyBroadcastManager binds new broadcaster + app(BroadcastManager::class)->driver(); + + tenancy()->end(); + + expect($originalBroadcaster)->toBe(app(BroadcasterContract::class)); +}); + test('BroadcastTenancyBootstrapper maps tenant broadcaster credentials to config as specified in the $credentialsMap property and reverts the config after ending tenancy', function() { config([ 'broadcasting.connections.testing.driver' => 'testing', @@ -396,7 +412,6 @@ test('broadcasters are created with the correct credentials', function() { expect(invade(app(BroadcastManager::class)->driver())->message)->toBe($tenantMessage); - tenancy()->end(); tenancy()->initialize($tenant2); $registerTestingBroadcaster();