File tree Expand file tree Collapse file tree 2 files changed +21
-5
lines changed Expand file tree Collapse file tree 2 files changed +21
-5
lines changed Original file line number Diff line number Diff line change 1313use Illuminate \Support \Str ;
1414use Illuminate \Validation \ValidationException ;
1515use Safe \Exceptions \JsonException ;
16- use stdClass ;
1716use UnexpectedValueException ;
1817use function Safe \json_decode ;
1918
@@ -98,11 +97,8 @@ private function captureTask($task): array
9897
9998 private function loadQueueConnectionConfiguration (array $ task ): void
10099 {
101- /**
102- * @var stdClass $command
103- */
104100 $ command = self ::getCommandProperties ($ task ['data ' ]['command ' ]);
105- $ connection = $ command-> connection ?? config ('queue.default ' );
101+ $ connection = $ command[ ' connection ' ] ?? config ('queue.default ' );
106102 $ baseConfig = config ('queue.connections. ' . $ connection );
107103 $ config = (new CloudTasksConnector ())->connect ($ baseConfig )->config ;
108104
Original file line number Diff line number Diff line change @@ -222,6 +222,26 @@ public function it_can_run_a_task()
222222 Log::assertLogged ('SimpleJob:success ' );
223223 }
224224
225+ /**
226+ * @test
227+ */
228+ public function it_can_run_a_task_using_the_task_connection ()
229+ {
230+ // Arrange
231+ OpenIdVerificator::fake ();
232+ Log::swap (new LogFake ());
233+ Event::fake ([JobProcessing::class, JobProcessed::class]);
234+ $ this ->app ['config ' ]->set ('queue.default ' , 'non-existing-connection ' );
235+
236+ // Act
237+ $ job = new SimpleJob ();
238+ $ job ->connection = 'my-cloudtasks-connection ' ;
239+ $ this ->dispatch ($ job )->runWithoutExceptionHandler ();
240+
241+ // Assert
242+ Log::assertLogged ('SimpleJob:success ' );
243+ }
244+
225245 /**
226246 * @test
227247 */
You can’t perform that action at this time.
0 commit comments