From ea3e90987b40c4025246d6e80b7487971d9c36e5 Mon Sep 17 00:00:00 2001 From: Abrar Ahmad Date: Thu, 1 Dec 2022 13:13:32 +0500 Subject: [PATCH] improve `tenants` assertions --- tests/ResourceSyncingUsingPolymorphicTest.php | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/tests/ResourceSyncingUsingPolymorphicTest.php b/tests/ResourceSyncingUsingPolymorphicTest.php index 13b6bb51..8abc703b 100644 --- a/tests/ResourceSyncingUsingPolymorphicTest.php +++ b/tests/ResourceSyncingUsingPolymorphicTest.php @@ -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();