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

minor test improvements

This commit is contained in:
Samuel Stancl 2026-07-20 20:17:54 -07:00
parent aa16736b64
commit d69c9f0a85
No known key found for this signature in database
GPG key ID: BA146259A1E16C57

View file

@ -12,7 +12,7 @@ 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;
$cleanup = function () { afterEach($cleanup = function () {
BroadcastingConfigBootstrapper::$broadcaster = null; BroadcastingConfigBootstrapper::$broadcaster = null;
BroadcastingConfigBootstrapper::$credentialsMap = []; BroadcastingConfigBootstrapper::$credentialsMap = [];
BroadcastingConfigBootstrapper::$mapPresets = [ BroadcastingConfigBootstrapper::$mapPresets = [
@ -33,7 +33,7 @@ $cleanup = function () {
'broadcasting.connections.ably.public' => 'ably_public', 'broadcasting.connections.ably.public' => 'ably_public',
], ],
]; ];
}; });
beforeEach(function () use ($cleanup) { beforeEach(function () use ($cleanup) {
Event::listen(TenancyInitialized::class, BootstrapTenancy::class); Event::listen(TenancyInitialized::class, BootstrapTenancy::class);
@ -42,8 +42,6 @@ beforeEach(function () use ($cleanup) {
$cleanup(); $cleanup();
}); });
afterEach($cleanup);
test('each context uses its own manager and broadcaster instances, and the bound broadcaster matches the manager default driver', function () { test('each context uses its own manager and broadcaster instances, and the bound broadcaster matches the manager default driver', function () {
config([ config([
'tenancy.bootstrappers' => [BroadcastingConfigBootstrapper::class], 'tenancy.bootstrappers' => [BroadcastingConfigBootstrapper::class],
@ -198,12 +196,15 @@ test('tenant broadcast manager receives the custom driver creators of the centra
); );
// Current BroadcastManager instance has the original custom creators plus the newly registered testing-tenant1 creator // Current BroadcastManager instance has the original custom creators plus the newly registered testing-tenant1 creator
expect(array_keys(invade(app(BroadcastManager::class))->customCreators))->toContain('testing');
expect(array_keys(invade(app(BroadcastManager::class))->customCreators))->toEqualCanonicalizing([...$originalDrivers, 'testing-tenant1']); expect(array_keys(invade(app(BroadcastManager::class))->customCreators))->toEqualCanonicalizing([...$originalDrivers, 'testing-tenant1']);
tenancy()->initialize($tenant2); tenancy()->initialize($tenant2);
// Current BroadcastManager only has the original custom creators, // Current BroadcastManager only has the original custom creators,
// the creator added in the previous tenant's context doesn't persist. // the creator added in the previous tenant's context doesn't persist.
expect(array_keys(invade(app(BroadcastManager::class))->customCreators))->toContain('testing');
expect(array_keys(invade(app(BroadcastManager::class))->customCreators))->not()->toContain('testing-tenant1');
expect(array_keys(invade(app(BroadcastManager::class))->customCreators))->toEqualCanonicalizing($originalDrivers); expect(array_keys(invade(app(BroadcastManager::class))->customCreators))->toEqualCanonicalizing($originalDrivers);
tenancy()->end(); tenancy()->end();