mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 06:04:03 +00:00
Make test clearer
This commit is contained in:
parent
0a8e5a141f
commit
05ebee24c4
1 changed files with 3 additions and 3 deletions
|
|
@ -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);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue