@@ -495,6 +495,54 @@ public function testBatchConditionable()
495
495
496
496
$ this ->assertEquals ('sync1 ' , $ batch ->connection ());
497
497
}
498
+
499
+ public function testJobsAreChainedWhenDispatchIfIsTrue ()
500
+ {
501
+ JobChainingTestFirstJob::withChain ([
502
+ new JobChainingTestSecondJob ,
503
+ ])->dispatchIf (true );
504
+
505
+ $ this ->runQueueWorkerCommand (['--stop-when-empty ' => true ]);
506
+
507
+ $ this ->assertTrue (JobChainingTestFirstJob::$ ran );
508
+ $ this ->assertTrue (JobChainingTestSecondJob::$ ran );
509
+ }
510
+
511
+ public function testJobsAreNotChainedWhenDispatchIfIsFalse ()
512
+ {
513
+ JobChainingTestFirstJob::withChain ([
514
+ new JobChainingTestSecondJob ,
515
+ ])->dispatchIf (false );
516
+
517
+ $ this ->runQueueWorkerCommand (['--stop-when-empty ' => true ]);
518
+
519
+ $ this ->assertFalse (JobChainingTestFirstJob::$ ran );
520
+ $ this ->assertFalse (JobChainingTestSecondJob::$ ran );
521
+ }
522
+
523
+ public function testJobsAreChainedWhenDispatchUnlessIsFalse ()
524
+ {
525
+ JobChainingTestFirstJob::withChain ([
526
+ new JobChainingTestSecondJob ,
527
+ ])->dispatchUnless (false );
528
+
529
+ $ this ->runQueueWorkerCommand (['--stop-when-empty ' => true ]);
530
+
531
+ $ this ->assertTrue (JobChainingTestFirstJob::$ ran );
532
+ $ this ->assertTrue (JobChainingTestSecondJob::$ ran );
533
+ }
534
+
535
+ public function testJobsAreNotChainedWhenDispatchUnlessIsTrue ()
536
+ {
537
+ JobChainingTestFirstJob::withChain ([
538
+ new JobChainingTestSecondJob ,
539
+ ])->dispatchUnless (true );
540
+
541
+ $ this ->runQueueWorkerCommand (['--stop-when-empty ' => true ]);
542
+
543
+ $ this ->assertFalse (JobChainingTestFirstJob::$ ran );
544
+ $ this ->assertFalse (JobChainingTestSecondJob::$ ran );
545
+ }
498
546
}
499
547
500
548
class JobChainingTestFirstJob implements ShouldQueue
0 commit comments