mirror of
https://github.com/archtechx/tenancy.git
synced 2026-08-06 06:54:03 +00:00
Add test for reverting the bound broadcaster when tenancy ends
The original BroadcastingTest file had a very similar test that was removed during a refactor. Added it back and improved it (used the testing broadcaster instead of NullBroadcaster, improved the test's name comments)
This commit is contained in:
parent
ddd8c68fbd
commit
614344af52
1 changed files with 23 additions and 0 deletions
|
|
@ -64,6 +64,29 @@ test('BroadcastingConfigBootstrapper binds TenancyBroadcastManager to BroadcastM
|
||||||
->not()->toBeInstanceOf(TenancyBroadcastManager::class);
|
->not()->toBeInstanceOf(TenancyBroadcastManager::class);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('ending tenancy reverts the bound broadcaster to the original instance', function() {
|
||||||
|
config([
|
||||||
|
'tenancy.bootstrappers' => [BroadcastingConfigBootstrapper::class],
|
||||||
|
'broadcasting.default' => 'testing',
|
||||||
|
'broadcasting.connections.testing.driver' => 'testing',
|
||||||
|
]);
|
||||||
|
TenancyBroadcastManager::$tenantBroadcasters = ['testing'];
|
||||||
|
|
||||||
|
app(BroadcastManager::class)->extend('testing', fn ($app, $config) => new TestingBroadcaster('testing', $config));
|
||||||
|
|
||||||
|
$originalBroadcaster = app(BroadcasterContract::class);
|
||||||
|
|
||||||
|
tenancy()->initialize(Tenant::create());
|
||||||
|
|
||||||
|
// BroadcastingConfigBootstrapper binds a freshly resolved broadcaster
|
||||||
|
expect(app(BroadcasterContract::class))->not()->toBe($originalBroadcaster);
|
||||||
|
|
||||||
|
tenancy()->end();
|
||||||
|
|
||||||
|
// Ending tenancy reverts the binding back to the original broadcaster instance
|
||||||
|
expect($originalBroadcaster)->toBe(app(BroadcasterContract::class));
|
||||||
|
});
|
||||||
|
|
||||||
test('BroadcastingConfigBootstrapper maps tenant properties to broadcaster credentials correctly', function(string $driver) {
|
test('BroadcastingConfigBootstrapper maps tenant properties to broadcaster credentials correctly', function(string $driver) {
|
||||||
config([
|
config([
|
||||||
'broadcasting.default' => $driver,
|
'broadcasting.default' => $driver,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue