1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 16:14:03 +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');
// Assert `tenants` are accessible
expect($centralUser->tenants->first())
->not()->toBeNull()
->id->toBe('t1');
expect($centralUser->tenants->first()->id)->toBe('t1');
// Assert User resource is synced
$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');
// Assert `tenants` are accessible
expect($centralCompany->tenants->first())
->not()->toBeNull()
->id->toBe('t2');
expect($centralCompany->tenants->first()->id)->toBe('t2');
// Assert Company resource is synced
$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();
// Assert `tenants` are accessible
expect($centralUser->tenants->first())
->not()->toBeNull()
->id->toBe('t1');
expect($centralUser->tenants->first()->id)->toBe('t1');
$centralUser = $centralUser->withoutRelations()->toArray();
$tenantUser = $tenantUser->toArray();
@ -166,9 +160,7 @@ test('resource syncing works using a single pivot table for multiple models when
$centralCompany = CentralCompanyUsingPolymorphic::first();
// Assert `tenants` are accessible
expect($centralCompany->tenants->first())
->not()->toBeNull()
->id->toBe('t2');
expect($centralCompany->tenants->first()->id)->toBe('t2');
$centralCompany = $centralCompany->withoutRelations()->toArray();
$tenantCompany = $tenantCompany->toArray();