mirror of
https://github.com/archtechx/tenancy.git
synced 2026-05-07 10:54:03 +00:00
Extract cleanup in broadcasting config test file
This commit is contained in:
parent
a7acd07e70
commit
7db486d1b9
1 changed files with 27 additions and 45 deletions
|
|
@ -13,56 +13,38 @@ use Stancl\Tenancy\Bootstrappers\BroadcastingConfigBootstrapper;
|
||||||
use Illuminate\Support\Facades\Broadcast;
|
use Illuminate\Support\Facades\Broadcast;
|
||||||
use Illuminate\Contracts\Broadcasting\Broadcaster as BroadcasterContract;
|
use Illuminate\Contracts\Broadcasting\Broadcaster as BroadcasterContract;
|
||||||
|
|
||||||
beforeEach(function () {
|
$cleanup = function () {
|
||||||
|
BroadcastingConfigBootstrapper::$broadcaster = null;
|
||||||
|
BroadcastingConfigBootstrapper::$credentialsMap = [];
|
||||||
|
BroadcastingConfigBootstrapper::$mapPresets = [
|
||||||
|
'pusher' => [
|
||||||
|
'broadcasting.connections.pusher.key' => 'pusher_key',
|
||||||
|
'broadcasting.connections.pusher.secret' => 'pusher_secret',
|
||||||
|
'broadcasting.connections.pusher.app_id' => 'pusher_app_id',
|
||||||
|
'broadcasting.connections.pusher.options.cluster' => 'pusher_cluster',
|
||||||
|
],
|
||||||
|
'reverb' => [
|
||||||
|
'broadcasting.connections.reverb.key' => 'reverb_key',
|
||||||
|
'broadcasting.connections.reverb.secret' => 'reverb_secret',
|
||||||
|
'broadcasting.connections.reverb.app_id' => 'reverb_app_id',
|
||||||
|
'broadcasting.connections.reverb.options.cluster' => 'reverb_cluster',
|
||||||
|
],
|
||||||
|
'ably' => [
|
||||||
|
'broadcasting.connections.ably.key' => 'ably_key',
|
||||||
|
'broadcasting.connections.ably.public' => 'ably_public',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
TenancyBroadcastManager::$tenantBroadcasters = ['pusher', 'ably', 'reverb'];
|
||||||
|
};
|
||||||
|
|
||||||
|
beforeEach(function () use ($cleanup) {
|
||||||
Event::listen(TenancyInitialized::class, BootstrapTenancy::class);
|
Event::listen(TenancyInitialized::class, BootstrapTenancy::class);
|
||||||
Event::listen(TenancyEnded::class, RevertToCentralContext::class);
|
Event::listen(TenancyEnded::class, RevertToCentralContext::class);
|
||||||
|
|
||||||
BroadcastingConfigBootstrapper::$broadcaster = null;
|
$cleanup();
|
||||||
BroadcastingConfigBootstrapper::$credentialsMap = [];
|
|
||||||
BroadcastingConfigBootstrapper::$mapPresets = [
|
|
||||||
'pusher' => [
|
|
||||||
'broadcasting.connections.pusher.key' => 'pusher_key',
|
|
||||||
'broadcasting.connections.pusher.secret' => 'pusher_secret',
|
|
||||||
'broadcasting.connections.pusher.app_id' => 'pusher_app_id',
|
|
||||||
'broadcasting.connections.pusher.options.cluster' => 'pusher_cluster',
|
|
||||||
],
|
|
||||||
'reverb' => [
|
|
||||||
'broadcasting.connections.reverb.key' => 'reverb_key',
|
|
||||||
'broadcasting.connections.reverb.secret' => 'reverb_secret',
|
|
||||||
'broadcasting.connections.reverb.app_id' => 'reverb_app_id',
|
|
||||||
'broadcasting.connections.reverb.options.cluster' => 'reverb_cluster',
|
|
||||||
],
|
|
||||||
'ably' => [
|
|
||||||
'broadcasting.connections.ably.key' => 'ably_key',
|
|
||||||
'broadcasting.connections.ably.public' => 'ably_public',
|
|
||||||
],
|
|
||||||
];
|
|
||||||
TenancyBroadcastManager::$tenantBroadcasters = ['pusher', 'ably', 'reverb'];
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach($cleanup);
|
||||||
BroadcastingConfigBootstrapper::$broadcaster = null;
|
|
||||||
BroadcastingConfigBootstrapper::$credentialsMap = [];
|
|
||||||
BroadcastingConfigBootstrapper::$mapPresets = [
|
|
||||||
'pusher' => [
|
|
||||||
'broadcasting.connections.pusher.key' => 'pusher_key',
|
|
||||||
'broadcasting.connections.pusher.secret' => 'pusher_secret',
|
|
||||||
'broadcasting.connections.pusher.app_id' => 'pusher_app_id',
|
|
||||||
'broadcasting.connections.pusher.options.cluster' => 'pusher_cluster',
|
|
||||||
],
|
|
||||||
'reverb' => [
|
|
||||||
'broadcasting.connections.reverb.key' => 'reverb_key',
|
|
||||||
'broadcasting.connections.reverb.secret' => 'reverb_secret',
|
|
||||||
'broadcasting.connections.reverb.app_id' => 'reverb_app_id',
|
|
||||||
'broadcasting.connections.reverb.options.cluster' => 'reverb_cluster',
|
|
||||||
],
|
|
||||||
'ably' => [
|
|
||||||
'broadcasting.connections.ably.key' => 'ably_key',
|
|
||||||
'broadcasting.connections.ably.public' => 'ably_public',
|
|
||||||
],
|
|
||||||
];
|
|
||||||
TenancyBroadcastManager::$tenantBroadcasters = ['pusher', 'ably', 'reverb'];
|
|
||||||
});
|
|
||||||
|
|
||||||
test('BroadcastingConfigBootstrapper binds TenancyBroadcastManager to BroadcastManager and reverts the binding when tenancy is ended', function() {
|
test('BroadcastingConfigBootstrapper binds TenancyBroadcastManager to BroadcastManager and reverts the binding when tenancy is ended', function() {
|
||||||
config(['tenancy.bootstrappers' => [BroadcastingConfigBootstrapper::class]]);
|
config(['tenancy.bootstrappers' => [BroadcastingConfigBootstrapper::class]]);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue