@@ -23,6 +23,9 @@ protected function tearDown(): void
2323 public function testCommandsThatShouldQueueIsQueued ()
2424 {
2525 $ container = new Container ;
26+ $ container ->instance ('queue.defaults ' , $ queueDefaults = m::mock ());
27+ $ queueDefaults ->shouldReceive ('get ' )->andReturn (null );
28+ Container::setInstance ($ container );
2629 $ dispatcher = new Dispatcher ($ container , function () {
2730 $ mock = m::mock (Queue::class);
2831 $ mock ->shouldReceive ('push ' )->once ();
@@ -36,6 +39,9 @@ public function testCommandsThatShouldQueueIsQueued()
3639 public function testCommandsThatShouldQueueIsQueuedUsingCustomHandler ()
3740 {
3841 $ container = new Container ;
42+ $ container ->instance ('queue.defaults ' , $ queueDefaults = m::mock ());
43+ $ queueDefaults ->shouldReceive ('get ' )->andReturn (null );
44+ Container::setInstance ($ container );
3945 $ dispatcher = new Dispatcher ($ container , function () {
4046 $ mock = m::mock (Queue::class);
4147 $ mock ->shouldReceive ('push ' )->once ();
@@ -49,6 +55,9 @@ public function testCommandsThatShouldQueueIsQueuedUsingCustomHandler()
4955 public function testCommandsThatShouldQueueIsQueuedUsingCustomQueueAndDelay ()
5056 {
5157 $ container = new Container ;
58+ $ container ->instance ('queue.defaults ' , $ queueDefaults = m::mock ());
59+ $ queueDefaults ->shouldReceive ('get ' )->andReturn (null );
60+ Container::setInstance ($ container );
5261 $ dispatcher = new Dispatcher ($ container , function () {
5362 $ mock = m::mock (Queue::class);
5463 $ mock ->shouldReceive ('later ' )->once ()->with (10 , m::type (BusDispatcherTestSpecificQueueAndDelayCommand::class), '' , 'foo ' );
@@ -59,6 +68,22 @@ public function testCommandsThatShouldQueueIsQueuedUsingCustomQueueAndDelay()
5968 $ dispatcher ->dispatch (new BusDispatcherTestSpecificQueueAndDelayCommand );
6069 }
6170
71+ public function testCommandsAreDispatchedWithDefaultQueue ()
72+ {
73+ $ container = new Container ;
74+ $ container ->instance ('queue.defaults ' , $ queueDefaults = m::mock ());
75+ $ queueDefaults ->shouldReceive ('get ' )->andReturn ('high-priority ' );
76+
77+ $ mock = m::mock (Queue::class);
78+ $ mock ->shouldReceive ('push ' )->once ()->with (BusDispatcherQueueable::class, '' , 'high-priority ' );
79+
80+ $ dispatcher = new Dispatcher ($ container , function () use ($ mock ) {
81+ return $ mock ;
82+ });
83+
84+ $ dispatcher ->dispatch (new BusDispatcherQueueable );
85+ }
86+
6287 public function testDispatchNowShouldNeverQueue ()
6388 {
6489 $ container = new Container ;
@@ -99,6 +124,9 @@ public function testOnConnectionOnJobWhenDispatching()
99124 ],
100125 ]);
101126 });
127+ $ container ->instance ('queue.defaults ' , $ queueDefaults = m::mock ());
128+ $ queueDefaults ->shouldReceive ('get ' )->andReturn (null );
129+ Container::setInstance ($ container );
102130
103131 $ dispatcher = new Dispatcher ($ container , function () {
104132 $ mock = m::mock (Queue::class);
@@ -147,6 +175,11 @@ class BusDispatcherTestSpecificQueueAndDelayCommand implements ShouldQueue
147175 public $ delay = 10 ;
148176}
149177
178+ class BusDispatcherQueueable implements ShouldQueue
179+ {
180+ use Queueable;
181+ }
182+
150183class StandAloneCommand
151184{
152185 //
0 commit comments