Skip to content

Commit e886e4e

Browse files
authored
batch a closure (#54587)
1 parent 8e9d24e commit e886e4e

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/Illuminate/Bus/PendingBatch.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function add($jobs)
9898
protected function ensureJobIsBatchable(object|array $job): void
9999
{
100100
foreach (Arr::wrap($job) as $job) {
101-
if ($job instanceof PendingBatch) {
101+
if ($job instanceof PendingBatch || $job instanceof Closure) {
102102
return;
103103
}
104104

tests/Bus/BusPendingBatchTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,17 @@ public function test_it_throws_an_exception_if_batched_job_contains_batch_with_n
244244
)
245245
);
246246
}
247+
248+
public function test_it_can_batch_a_closure(): void
249+
{
250+
new PendingBatch(
251+
new Container,
252+
new Collection([
253+
function() {}
254+
])
255+
);
256+
$this->expectNotToPerformAssertions();
257+
}
247258
}
248259

249260
class BatchableJob

0 commit comments

Comments
 (0)