1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-08-06 09:54:03 +00:00

Assert that the bound broadcaster and the manager's default driver are in sync in all contexts

This commit is contained in:
lukinovec 2026-07-17 10:27:21 +02:00
parent fe7468ab72
commit 23149473a9

View file

@ -60,7 +60,7 @@ test('BroadcastingConfigBootstrapper binds a fresh BroadcastManager and reverts
expect(app(BroadcastManager::class))->toBe($centralManager); expect(app(BroadcastManager::class))->toBe($centralManager);
}); });
test('ending tenancy reverts the bound broadcaster to the original instance', function () { test('bound broadcaster matches the manager default driver in every context and ending tenancy reverts it to the original instance', function () {
config([ config([
'tenancy.bootstrappers' => [BroadcastingConfigBootstrapper::class], 'tenancy.bootstrappers' => [BroadcastingConfigBootstrapper::class],
'broadcasting.default' => 'testing', 'broadcasting.default' => 'testing',
@ -71,6 +71,9 @@ test('ending tenancy reverts the bound broadcaster to the original instance', fu
$originalBroadcaster = app(BroadcasterContract::class); $originalBroadcaster = app(BroadcasterContract::class);
// The bound broadcaster and the manager's default driver should be the same instance in every context
expect(app(BroadcasterContract::class))->toBe(app(BroadcastManager::class)->driver());
tenancy()->initialize(Tenant::create()); tenancy()->initialize(Tenant::create());
// BroadcastingConfigBootstrapper binds a freshly resolved broadcaster // BroadcastingConfigBootstrapper binds a freshly resolved broadcaster
@ -83,6 +86,8 @@ test('ending tenancy reverts the bound broadcaster to the original instance', fu
// Ending tenancy reverts the binding back to the original broadcaster instance // Ending tenancy reverts the binding back to the original broadcaster instance
expect($originalBroadcaster)->toBe(app(BroadcasterContract::class)); expect($originalBroadcaster)->toBe(app(BroadcasterContract::class));
// The bound broadcaster is still the same as the central manager's default driver
expect(app(BroadcasterContract::class))->toBe(app(BroadcastManager::class)->driver());
}); });
test('BroadcastingConfigBootstrapper maps tenant properties to broadcaster credentials correctly', function (string $driver) { test('BroadcastingConfigBootstrapper maps tenant properties to broadcaster credentials correctly', function (string $driver) {