@@ -288,6 +288,30 @@ public function testChainJobsCanBeAppended()
288288 $ this ->assertTrue (JobChainAddingAddedJob::$ ranAt ->isAfter (JobChainAddingExistingJob::$ ranAt ));
289289 }
290290
291+ public function testChainJobsCanBePrependedBatch ()
292+ {
293+ Bus::chain ([
294+ new JobChainAddingPrependedBatch ('j1 ' ),
295+ new JobChainingNamedTestJob ('j2 ' ),
296+ ])->dispatch ();
297+
298+ $ this ->runQueueWorkerCommand (['--stop-when-empty ' => true ]);
299+
300+ $ this ->assertEquals (['j1 ' , 'b1 ' , 'b2 ' , 'j2 ' ], JobRunRecorder::$ results );
301+ }
302+
303+ public function testChainJobsCanBeAppendedBatch ()
304+ {
305+ Bus::chain ([
306+ new JobChainAddingAppendingBatch ('j1 ' ),
307+ new JobChainingNamedTestJob ('j2 ' ),
308+ ])->dispatch ();
309+
310+ $ this ->runQueueWorkerCommand (['--stop-when-empty ' => true ]);
311+
312+ $ this ->assertEquals (['j1 ' , 'j2 ' , 'b1 ' , 'b2 ' ], JobRunRecorder::$ results );
313+ }
314+
291315 public function testChainJobsCanBeAppendedWithoutExistingChain ()
292316 {
293317 JobChainAddingAppendingJob::dispatch ();
@@ -652,6 +676,50 @@ public function handle()
652676 }
653677}
654678
679+ class JobChainAddingAppendingBatch implements ShouldQueue
680+ {
681+ use Dispatchable, InteractsWithQueue, Queueable;
682+
683+ public string $ id ;
684+
685+ public function __construct (string $ id )
686+ {
687+ $ this ->id = $ id ;
688+ }
689+
690+ public function handle ()
691+ {
692+ $ this ->appendToChain (Bus::batch ([
693+ new JobChainingNamedTestJob ('b1 ' ),
694+ new JobChainingNamedTestJob ('b2 ' ),
695+ ]));
696+
697+ JobRunRecorder::record ($ this ->id );
698+ }
699+ }
700+
701+ class JobChainAddingPrependedBatch implements ShouldQueue
702+ {
703+ use Dispatchable, InteractsWithQueue, Queueable;
704+
705+ public string $ id ;
706+
707+ public function __construct (string $ id )
708+ {
709+ $ this ->id = $ id ;
710+ }
711+
712+ public function handle ()
713+ {
714+ $ this ->prependToChain (Bus::batch ([
715+ new JobChainingNamedTestJob ('b1 ' ),
716+ new JobChainingNamedTestJob ('b2 ' ),
717+ ]));
718+
719+ JobRunRecorder::record ($ this ->id );
720+ }
721+ }
722+
655723class JobChainAddingExistingJob implements ShouldQueue
656724{
657725 use Dispatchable, InteractsWithQueue, Queueable;
0 commit comments