Skip to content

Commit aa16736

Browse files
committed
Merge the BroadcastManager binding test into the broadcaster instance test
1 parent 64538ea commit aa16736

1 file changed

Lines changed: 8 additions & 20 deletions

File tree

tests/Bootstrappers/BroadcastingConfigBootstrapperTest.php

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,7 @@
4444

4545
afterEach($cleanup);
4646

47-
test('BroadcastingConfigBootstrapper binds a fresh BroadcastManager and reverts the binding when tenancy is ended', function () {
48-
config(['tenancy.bootstrappers' => [BroadcastingConfigBootstrapper::class]]);
49-
50-
$centralManager = app(BroadcastManager::class);
51-
52-
tenancy()->initialize(Tenant::create());
53-
54-
expect(app(BroadcastManager::class))
55-
->toBeInstanceOf(BroadcastManager::class)
56-
->not()->toBe($centralManager);
57-
58-
tenancy()->end();
59-
60-
expect(app(BroadcastManager::class))->toBe($centralManager);
61-
});
62-
63-
test('bound broadcaster matches the manager default driver in every context and ending tenancy reverts it to the original instance', function () {
47+
test('each context uses its own manager and broadcaster instances, and the bound broadcaster matches the manager default driver', function () {
6448
config([
6549
'tenancy.bootstrappers' => [BroadcastingConfigBootstrapper::class],
6650
'broadcasting.default' => 'testing',
@@ -69,23 +53,27 @@
6953

7054
app(BroadcastManager::class)->extend('testing', fn ($app, $config) => new TestingBroadcaster('testing', $config));
7155

56+
$originalManager = app(BroadcastManager::class);
7257
$originalBroadcaster = app(BroadcasterContract::class);
7358

7459
// The bound broadcaster and the manager's default driver should be the same instance in every context
7560
expect(app(BroadcasterContract::class))->toBe(app(BroadcastManager::class)->driver());
7661

7762
tenancy()->initialize(Tenant::create());
7863

79-
// BroadcastingConfigBootstrapper binds a freshly resolved broadcaster
64+
// BroadcastingConfigBootstrapper binds a fresh manager and a freshly resolved broadcaster
65+
expect(app(BroadcastManager::class))->not()->toBe($originalManager);
8066
expect(app(BroadcasterContract::class))->not()->toBe($originalBroadcaster);
8167

8268
// The bound broadcaster is the same instance as the tenant BroadcastManager's default driver
8369
expect(app(BroadcasterContract::class))->toBe(app(BroadcastManager::class)->driver());
8470

8571
tenancy()->end();
8672

87-
// Ending tenancy reverts the binding back to the original broadcaster instance
88-
expect($originalBroadcaster)->toBe(app(BroadcasterContract::class));
73+
// Ending tenancy reverts the bindings back to the original instances
74+
expect(app(BroadcastManager::class))->toBe($originalManager);
75+
expect(app(BroadcasterContract::class))->toBe($originalBroadcaster);
76+
8977
// The bound broadcaster is still the same as the central manager's default driver
9078
expect(app(BroadcasterContract::class))->toBe(app(BroadcastManager::class)->driver());
9179
});

0 commit comments

Comments
 (0)