Skip to content

Commit 097caee

Browse files
committed
Merge branch '7.x' of https://github.com/lupinitylabs/framework into lupinitylabs-7.x
2 parents dcda66d + 6592443 commit 097caee

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

src/Illuminate/Events/Dispatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ protected function queueHandler($class, $method, $arguments)
489489
$listener->connection ?? null
490490
);
491491

492-
$queue = $listener->queue ?? null;
492+
$queue = method_exists($listener, 'getQueue') ? $listener->getQueue() : $listener->queue ?? null;
493493

494494
isset($listener->delay)
495495
? $connection->laterOn($queue, $listener->delay, $job)

tests/Events/QueuedEventsTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,22 @@ public function testCustomizedQueuedEventHandlersAreQueued()
5050

5151
$fakeQueue->assertPushedOn('my_queue', CallQueuedListener::class);
5252
}
53+
54+
public function testQueueIsSetByGetQueue()
55+
{
56+
$d = new Dispatcher;
57+
58+
$fakeQueue = new QueueFake(new Container());
59+
60+
$d->setQueueResolver(function () use ($fakeQueue) {
61+
return $fakeQueue;
62+
});
63+
64+
$d->listen('some.event', TestDispatcherGetQueue::class.'@handle');
65+
$d->dispatch('some.event', ['foo', 'bar']);
66+
67+
$fakeQueue->assertPushedOn('some_other_queue', CallQueuedListener::class);
68+
}
5369
}
5470

5571
class TestDispatcherQueuedHandler implements ShouldQueue
@@ -73,3 +89,18 @@ public function handle()
7389
//
7490
}
7591
}
92+
93+
class TestDispatcherGetQueue implements ShouldQueue
94+
{
95+
public $queue = 'my_queue';
96+
97+
public function handle()
98+
{
99+
//
100+
}
101+
102+
public function getQueue()
103+
{
104+
return 'some_other_queue';
105+
}
106+
}

0 commit comments

Comments
 (0)