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

improve tenants assertions

This commit is contained in:
Abrar Ahmad 2022-12-01 13:13:32 +05:00
parent fb847830d5
commit ea3e90987b

View file

@ -73,9 +73,7 @@ test('resource syncing works using a single pivot table for multiple models when
$centralUser->tenants()->attach('t1'); $centralUser->tenants()->attach('t1');
// Assert `tenants` are accessible // Assert `tenants` are accessible
expect($centralUser->tenants->first()) expect($centralUser->tenants->first()->id)->toBe('t1');
->not()->toBeNull()
->id->toBe('t1');
// Assert User resource is synced // Assert User resource is synced
$tenant1->run(function () use ($centralUser) { $tenant1->run(function () use ($centralUser) {
@ -102,9 +100,7 @@ test('resource syncing works using a single pivot table for multiple models when
$centralCompany->tenants()->attach('t2'); $centralCompany->tenants()->attach('t2');
// Assert `tenants` are accessible // Assert `tenants` are accessible
expect($centralCompany->tenants->first()) expect($centralCompany->tenants->first()->id)->toBe('t2');
->not()->toBeNull()
->id->toBe('t2');
// Assert Company resource is synced // Assert Company resource is synced
$tenant2->run(function () use ($centralCompany) { $tenant2->run(function () use ($centralCompany) {
@ -136,9 +132,7 @@ test('resource syncing works using a single pivot table for multiple models when
$centralUser = CentralUserUsingPolymorphic::first(); $centralUser = CentralUserUsingPolymorphic::first();
// Assert `tenants` are accessible // Assert `tenants` are accessible
expect($centralUser->tenants->first()) expect($centralUser->tenants->first()->id)->toBe('t1');
->not()->toBeNull()
->id->toBe('t1');
$centralUser = $centralUser->withoutRelations()->toArray(); $centralUser = $centralUser->withoutRelations()->toArray();
$tenantUser = $tenantUser->toArray(); $tenantUser = $tenantUser->toArray();
@ -166,9 +160,7 @@ test('resource syncing works using a single pivot table for multiple models when
$centralCompany = CentralCompanyUsingPolymorphic::first(); $centralCompany = CentralCompanyUsingPolymorphic::first();
// Assert `tenants` are accessible // Assert `tenants` are accessible
expect($centralCompany->tenants->first()) expect($centralCompany->tenants->first()->id)->toBe('t2');
->not()->toBeNull()
->id->toBe('t2');
$centralCompany = $centralCompany->withoutRelations()->toArray(); $centralCompany = $centralCompany->withoutRelations()->toArray();
$tenantCompany = $tenantCompany->toArray(); $tenantCompany = $tenantCompany->toArray();