Skip to content

Commit d10ab79

Browse files
authored
wip (#41475)
1 parent 0b4f74b commit d10ab79

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/Illuminate/Bus/PendingBatch.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ public function __construct(Container $container, Collection $jobs)
5757
/**
5858
* Add jobs to the batch.
5959
*
60-
* @param iterable $jobs
60+
* @param \Illuminate\Support\Enumerable|object|array $jobs
6161
* @return $this
6262
*/
6363
public function add($jobs)
6464
{
65-
foreach ($jobs as $job) {
65+
foreach (Arr::wrap($jobs) as $job) {
6666
$this->jobs->push($job);
6767
}
6868

tests/Bus/BusBatchTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,28 @@ public function test_jobs_can_be_added_to_the_batch()
117117
$this->assertInstanceOf(CarbonImmutable::class, $batch->createdAt);
118118
}
119119

120+
public function test_jobs_can_be_added_to_pending_batch()
121+
{
122+
$batch = new PendingBatch(new Container, collect());
123+
$this->assertCount(0, $batch->jobs);
124+
125+
$job = new class
126+
{
127+
use Batchable;
128+
};
129+
$batch->add([$job]);
130+
$this->assertCount(1, $batch->jobs);
131+
132+
$secondJob = new class
133+
{
134+
use Batchable;
135+
136+
public $anotherProperty;
137+
};
138+
$batch->add($secondJob);
139+
$this->assertCount(2, $batch->jobs);
140+
}
141+
120142
public function test_processed_jobs_can_be_calculated()
121143
{
122144
$queue = m::mock(Factory::class);

0 commit comments

Comments
 (0)