From d69c9f0a85ef23e172f92876c30dfc5d532ca2af Mon Sep 17 00:00:00 2001 From: Samuel Stancl Date: Mon, 20 Jul 2026 20:17:54 -0700 Subject: [PATCH] minor test improvements --- .../Bootstrappers/BroadcastingConfigBootstrapperTest.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/Bootstrappers/BroadcastingConfigBootstrapperTest.php b/tests/Bootstrappers/BroadcastingConfigBootstrapperTest.php index a08aa40e..478f299d 100644 --- a/tests/Bootstrappers/BroadcastingConfigBootstrapperTest.php +++ b/tests/Bootstrappers/BroadcastingConfigBootstrapperTest.php @@ -12,7 +12,7 @@ use Stancl\Tenancy\Bootstrappers\BroadcastingConfigBootstrapper; use Illuminate\Support\Facades\Broadcast; use Illuminate\Contracts\Broadcasting\Broadcaster as BroadcasterContract; -$cleanup = function () { +afterEach($cleanup = function () { BroadcastingConfigBootstrapper::$broadcaster = null; BroadcastingConfigBootstrapper::$credentialsMap = []; BroadcastingConfigBootstrapper::$mapPresets = [ @@ -33,7 +33,7 @@ $cleanup = function () { 'broadcasting.connections.ably.public' => 'ably_public', ], ]; -}; +}); beforeEach(function () use ($cleanup) { Event::listen(TenancyInitialized::class, BootstrapTenancy::class); @@ -42,8 +42,6 @@ beforeEach(function () use ($cleanup) { $cleanup(); }); -afterEach($cleanup); - test('each context uses its own manager and broadcaster instances, and the bound broadcaster matches the manager default driver', function () { config([ 'tenancy.bootstrappers' => [BroadcastingConfigBootstrapper::class], @@ -198,12 +196,15 @@ test('tenant broadcast manager receives the custom driver creators of the centra ); // Current BroadcastManager instance has the original custom creators plus the newly registered testing-tenant1 creator + expect(array_keys(invade(app(BroadcastManager::class))->customCreators))->toContain('testing'); expect(array_keys(invade(app(BroadcastManager::class))->customCreators))->toEqualCanonicalizing([...$originalDrivers, 'testing-tenant1']); tenancy()->initialize($tenant2); // Current BroadcastManager only has the original custom creators, // the creator added in the previous tenant's context doesn't persist. + expect(array_keys(invade(app(BroadcastManager::class))->customCreators))->toContain('testing'); + expect(array_keys(invade(app(BroadcastManager::class))->customCreators))->not()->toContain('testing-tenant1'); expect(array_keys(invade(app(BroadcastManager::class))->customCreators))->toEqualCanonicalizing($originalDrivers); tenancy()->end();