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

Make test clearer

This commit is contained in:
lukinovec 2025-06-03 09:21:30 +02:00
parent 0a8e5a141f
commit 05ebee24c4

View file

@ -111,12 +111,12 @@ afterEach(function () {
UpdateOrCreateSyncedResource::$scopeGetModelQuery = null; UpdateOrCreateSyncedResource::$scopeGetModelQuery = null;
}); });
test('multiple tenants can have users synced to a central resource', function () { test('creating the same user across multiple tenants does not create multiple central resources', function () {
$tenants = [Tenant::create(), Tenant::create(), Tenant::create()]; $tenants = [Tenant::create(), Tenant::create(), Tenant::create()];
migrateUsersTableForTenants(); migrateUsersTableForTenants();
tenancy()->runForMultiple($tenants, function () { tenancy()->runForMultiple($tenants, function () {
// Create a user in tenant DB // Create a user with the same global_id in each tenant DB
TenantUser::create([ TenantUser::create([
'global_id' => 'acme', 'global_id' => 'acme',
'name' => Str::random(), 'name' => Str::random(),
@ -126,7 +126,7 @@ test('multiple tenants can have users synced to a central resource', function ()
]); ]);
}); });
// Create the same user in tenant DB // Assert only one central user was created despite being created in multiple tenant DBs
$users = CentralUser::where(['global_id' => 'acme'])->get(); $users = CentralUser::where(['global_id' => 'acme'])->get();
expect($users)->toHaveCount(1); expect($users)->toHaveCount(1);