diff --git a/src/Scout/ScoutEngine.php b/src/Scout/ScoutEngine.php index 9455608bb..284a178fa 100644 --- a/src/Scout/ScoutEngine.php +++ b/src/Scout/ScoutEngine.php @@ -151,7 +151,7 @@ public function update($models) #[Override] public function delete($models): void { - assert($models instanceof EloquentCollection, new TypeError(sprintf('Argument #1 ($models) must be of type %s, %s given', Collection::class, get_debug_type($models)))); + assert($models instanceof EloquentCollection, new TypeError(sprintf('Argument #1 ($models) must be of type %s, %s given', EloquentCollection::class, get_debug_type($models)))); if ($models->isEmpty()) { return; diff --git a/tests/Scout/ScoutEngineTest.php b/tests/Scout/ScoutEngineTest.php index 7b254ec9c..8cddbc040 100644 --- a/tests/Scout/ScoutEngineTest.php +++ b/tests/Scout/ScoutEngineTest.php @@ -670,4 +670,17 @@ public function testDeleteWithRemoveableScoutCollection(): void $engine = new ScoutEngine($database, softDelete: false); $engine->delete($job->models); } + + public function testDeleteRejectsNonEloquentCollection(): void + { + $database = $this->createMock(Database::class); + $engine = new ScoutEngine($database, softDelete: false); + + $this->expectException(\TypeError::class); + $this->expectExceptionMessage( + 'Argument #1 ($models) must be of type Illuminate\Database\Eloquent\Collection' + ); + + $engine->delete(LaravelCollection::make([1, 2, 3])); + } }