From 2ea7b84d72262dcd8ce6e6fd18fd58c7d06d68ed Mon Sep 17 00:00:00 2001 From: Italo Date: Fri, 25 Jul 2025 08:27:24 -0400 Subject: [PATCH 1/2] [12.x] Adds support for multiple models on single assertion call --- database-testing.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/database-testing.md b/database-testing.md index a2525eb2d03..0eaa713540b 100644 --- a/database-testing.md +++ b/database-testing.md @@ -254,7 +254,7 @@ $this->assertNotSoftDeleted($user); #### assertModelExists -Assert that a given model exists in the database: +Assert that a given model, or collection of models, exist in the database: ```php use App\Models\User; @@ -262,12 +262,16 @@ use App\Models\User; $user = User::factory()->create(); $this->assertModelExists($user); + +$users = User::factory()->count(5)->create(); + +$this->assertModelExists($users); ``` #### assertModelMissing -Assert that a given model does not exist in the database: +Assert that a given model, or collection of models, do not exist in the database: ```php use App\Models\User; @@ -277,6 +281,12 @@ $user = User::factory()->create(); $user->delete(); $this->assertModelMissing($user); + +$users = User::factory()->count(5)->create(); + +$users->each->delete(); + +$this->assertModelMissing($users); ``` From 16542304f2abe19c10392f78fde185ea74fa947c Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 25 Jul 2025 08:48:31 -0600 Subject: [PATCH 2/2] Update database-testing.md --- database-testing.md | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/database-testing.md b/database-testing.md index 0eaa713540b..8f6bf6e0b6a 100644 --- a/database-testing.md +++ b/database-testing.md @@ -254,7 +254,7 @@ $this->assertNotSoftDeleted($user); #### assertModelExists -Assert that a given model, or collection of models, exist in the database: +Assert that a given model or collection of models exist in the database: ```php use App\Models\User; @@ -262,16 +262,12 @@ use App\Models\User; $user = User::factory()->create(); $this->assertModelExists($user); - -$users = User::factory()->count(5)->create(); - -$this->assertModelExists($users); ``` #### assertModelMissing -Assert that a given model, or collection of models, do not exist in the database: +Assert that a given model or collection of models do not exist in the database: ```php use App\Models\User; @@ -281,12 +277,6 @@ $user = User::factory()->create(); $user->delete(); $this->assertModelMissing($user); - -$users = User::factory()->count(5)->create(); - -$users->each->delete(); - -$this->assertModelMissing($users); ```