Skip to content

Commit b8fddf8

Browse files
committed
Retrieve the re-registered channel closure to assert what tenant_channel() actually stored
#1448 (comment)
1 parent af14d40 commit b8fddf8

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

tests/Bootstrappers/BroadcastChannelPrefixBootstrapperTest.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,16 @@ protected function formatChannels(array $channels)
208208
return User::firstWhere('name', $userName)?->is($user) ?? false;
209209
});
210210

211-
expect($tenantChannelClosure)->not()->toBe($centralChannelClosure);
211+
// Retrieve the stored closure to verify that re-registering the channel replaced it
212+
// (asserting on $tenantChannelClosure wouldn't tell us what tenant_channel() actually stored)
213+
$reregisteredTenantChannelClosure = $getChannels()->first(fn ($closure, $name) => $name === "{tenant}.$channelName");
212214

213-
expect($tenantChannelClosure($centralUser, $tenant->getTenantKey(), $centralUser->name))->toBeTrue();
214-
expect($tenantChannelClosure($centralUser, $tenant->getTenantKey(), $tenantUser->name))->toBeFalse();
215+
expect($reregisteredTenantChannelClosure)
216+
->toBe($tenantChannelClosure)
217+
->not()->toBe($centralChannelClosure);
218+
219+
expect($reregisteredTenantChannelClosure($centralUser, $tenant->getTenantKey(), $centralUser->name))->toBeTrue();
220+
expect($reregisteredTenantChannelClosure($centralUser, $tenant->getTenantKey(), $tenantUser->name))->toBeFalse();
215221

216222
tenancy()->initialize($tenant);
217223

0 commit comments

Comments
 (0)