Skip to content

Commit 84ba139

Browse files
committed
Merge branch 'orkhanahmadov/8.x' into 8.x
2 parents 4b06bb4 + 51bb8a3 commit 84ba139

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/Illuminate/Bus/PendingBatch.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,20 @@ public function queue()
226226
return $this->options['queue'] ?? null;
227227
}
228228

229+
/**
230+
* Add additional data into the batch's options array.
231+
*
232+
* @param string $key
233+
* @param mixed $value
234+
* @return $this
235+
*/
236+
public function withOption(string $key, $value)
237+
{
238+
$this->options[$key] = $value;
239+
240+
return $this;
241+
}
242+
229243
/**
230244
* Dispatch the batch.
231245
*

tests/Bus/BusPendingBatchTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,14 @@ public function test_pending_batch_may_be_configured_and_dispatched()
4141
//
4242
})->catch(function () {
4343
//
44-
})->allowFailures()->onConnection('test-connection')->onQueue('test-queue');
44+
})->allowFailures()->onConnection('test-connection')->onQueue('test-queue')->withOption('extra-option', 123);
4545

4646
$this->assertSame('test-connection', $pendingBatch->connection());
4747
$this->assertSame('test-queue', $pendingBatch->queue());
4848
$this->assertCount(1, $pendingBatch->thenCallbacks());
4949
$this->assertCount(1, $pendingBatch->catchCallbacks());
50+
$this->assertArrayHasKey('extra-option', $pendingBatch->options);
51+
$this->assertSame(123, $pendingBatch->options['extra-option']);
5052

5153
$repository = m::mock(BatchRepository::class);
5254
$repository->shouldReceive('store')->once()->with($pendingBatch)->andReturn($batch = m::mock(stdClass::class));

0 commit comments

Comments
 (0)