File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -226,6 +226,20 @@ public function queue()
226
226
return $ this ->options ['queue ' ] ?? null ;
227
227
}
228
228
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
+
229
243
/**
230
244
* Dispatch the batch.
231
245
*
Original file line number Diff line number Diff line change @@ -41,12 +41,14 @@ public function test_pending_batch_may_be_configured_and_dispatched()
41
41
//
42
42
})->catch (function () {
43
43
//
44
- })->allowFailures ()->onConnection ('test-connection ' )->onQueue ('test-queue ' );
44
+ })->allowFailures ()->onConnection ('test-connection ' )->onQueue ('test-queue ' )-> withOption ( ' extra-option ' , 123 ) ;
45
45
46
46
$ this ->assertSame ('test-connection ' , $ pendingBatch ->connection ());
47
47
$ this ->assertSame ('test-queue ' , $ pendingBatch ->queue ());
48
48
$ this ->assertCount (1 , $ pendingBatch ->thenCallbacks ());
49
49
$ this ->assertCount (1 , $ pendingBatch ->catchCallbacks ());
50
+ $ this ->assertArrayHasKey ('extra-option ' , $ pendingBatch ->options );
51
+ $ this ->assertSame (123 , $ pendingBatch ->options ['extra-option ' ]);
50
52
51
53
$ repository = m::mock (BatchRepository::class);
52
54
$ repository ->shouldReceive ('store ' )->once ()->with ($ pendingBatch )->andReturn ($ batch = m::mock (stdClass::class));
You can’t perform that action at this time.
0 commit comments