mirror of
https://github.com/archtechx/tenancy.git
synced 2026-05-06 18:04:03 +00:00
BroadcastingTest: update channel inheritance test
Test that the bound Broadcaster instance inherits the channels too. Also test that the channels aren't lost when switching context to another tenant.
This commit is contained in:
parent
b6c035c912
commit
bbe2ff02df
1 changed files with 22 additions and 6 deletions
|
|
@ -137,7 +137,7 @@ test('tenant broadcast manager receives the custom driver creators of the centra
|
||||||
expect(array_keys(invade(app(BroadcastManager::class))->customCreators))->toBe($originalDrivers);
|
expect(array_keys(invade(app(BroadcastManager::class))->customCreators))->toBe($originalDrivers);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('new broadcasters get the channels from the previously bound broadcaster', function() {
|
test('tenant broadcasters receive the channels from the broadcaster bound in central context', function() {
|
||||||
config(['tenancy.bootstrappers' => [BroadcastingConfigBootstrapper::class]]);
|
config(['tenancy.bootstrappers' => [BroadcastingConfigBootstrapper::class]]);
|
||||||
config([
|
config([
|
||||||
'broadcasting.default' => $driver = 'testing',
|
'broadcasting.default' => $driver = 'testing',
|
||||||
|
|
@ -146,20 +146,36 @@ test('new broadcasters get the channels from the previously bound broadcaster',
|
||||||
|
|
||||||
TenancyBroadcastManager::$tenantBroadcasters[] = $driver;
|
TenancyBroadcastManager::$tenantBroadcasters[] = $driver;
|
||||||
|
|
||||||
|
$tenant1 = Tenant::create();
|
||||||
|
$tenant2 = Tenant::create();
|
||||||
|
|
||||||
app(BroadcastManager::class)->extend('testing', fn($app, $config) => new TestingBroadcaster('testing'));
|
app(BroadcastManager::class)->extend('testing', fn($app, $config) => new TestingBroadcaster('testing'));
|
||||||
$getCurrentChannels = fn() => array_keys(invade(app(BroadcastManager::class)->driver())->channels);
|
$getCurrentChannelsFromBoundBroadcaster = fn() => array_keys(invade(app(BroadcasterContract::class))->channels);
|
||||||
|
$getCurrentChannelsThroughManager = fn() => array_keys(invade(app(BroadcastManager::class)->driver())->channels);
|
||||||
|
|
||||||
Broadcast::channel($channel = 'testing-channel', fn() => true);
|
Broadcast::channel($channel = 'testing-channel', fn() => true);
|
||||||
|
|
||||||
expect($channel)->toBeIn($getCurrentChannels());
|
expect($channel)
|
||||||
|
->toBeIn($getCurrentChannelsThroughManager())
|
||||||
|
->toBeIn($getCurrentChannelsFromBoundBroadcaster());
|
||||||
|
|
||||||
tenancy()->initialize(Tenant::create());
|
tenancy()->initialize($tenant1);
|
||||||
|
|
||||||
expect($channel)->toBeIn($getCurrentChannels());
|
expect($channel)
|
||||||
|
->toBeIn($getCurrentChannelsThroughManager())
|
||||||
|
->toBeIn($getCurrentChannelsFromBoundBroadcaster());
|
||||||
|
|
||||||
|
tenancy()->initialize($tenant2);
|
||||||
|
|
||||||
|
expect($channel)
|
||||||
|
->toBeIn($getCurrentChannelsThroughManager())
|
||||||
|
->toBeIn($getCurrentChannelsFromBoundBroadcaster());
|
||||||
|
|
||||||
tenancy()->end();
|
tenancy()->end();
|
||||||
|
|
||||||
expect($channel)->toBeIn($getCurrentChannels());
|
expect($channel)
|
||||||
|
->toBeIn($getCurrentChannelsThroughManager())
|
||||||
|
->toBeIn($getCurrentChannelsFromBoundBroadcaster());
|
||||||
});
|
});
|
||||||
|
|
||||||
test('broadcasting channel helpers register channels correctly', function() {
|
test('broadcasting channel helpers register channels correctly', function() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue