Skip to content

Commit 1846a65

Browse files
committed
fix: delete method error message
1 parent dee170a commit 1846a65

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/Scout/ScoutEngine.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public function update($models)
151151
#[Override]
152152
public function delete($models): void
153153
{
154-
assert($models instanceof EloquentCollection, new TypeError(sprintf('Argument #1 ($models) must be of type %s, %s given', Collection::class, get_debug_type($models))));
154+
assert($models instanceof EloquentCollection, new TypeError(sprintf('Argument #1 ($models) must be of type %s, %s given', EloquentCollection::class, get_debug_type($models))));
155155

156156
if ($models->isEmpty()) {
157157
return;

tests/Scout/ScoutEngineTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,4 +670,17 @@ public function testDeleteWithRemoveableScoutCollection(): void
670670
$engine = new ScoutEngine($database, softDelete: false);
671671
$engine->delete($job->models);
672672
}
673+
674+
public function testDeleteRejectsNonEloquentCollection(): void
675+
{
676+
$database = $this->createMock(Database::class);
677+
$engine = new ScoutEngine($database, softDelete: false);
678+
679+
$this->expectException(\TypeError::class);
680+
$this->expectExceptionMessage(
681+
'Argument #1 ($models) must be of type Illuminate\Database\Eloquent\Collection'
682+
);
683+
684+
$engine->delete(LaravelCollection::make([1, 2, 3]));
685+
}
673686
}

0 commit comments

Comments
 (0)