Skip to content

Commit

Permalink
Merge branch '7.x' of https://github.com/lupinitylabs/framework into …
Browse files Browse the repository at this point in the history
…lupinitylabs-7.x
  • Loading branch information
taylorotwell committed Jun 8, 2020
2 parents dcda66d + 6592443 commit 097caee
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Illuminate/Events/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ protected function queueHandler($class, $method, $arguments)
$listener->connection ?? null
);

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

isset($listener->delay)
? $connection->laterOn($queue, $listener->delay, $job)
Expand Down
31 changes: 31 additions & 0 deletions tests/Events/QueuedEventsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@ public function testCustomizedQueuedEventHandlersAreQueued()

$fakeQueue->assertPushedOn('my_queue', CallQueuedListener::class);
}

public function testQueueIsSetByGetQueue()
{
$d = new Dispatcher;

$fakeQueue = new QueueFake(new Container());

$d->setQueueResolver(function () use ($fakeQueue) {
return $fakeQueue;
});

$d->listen('some.event', TestDispatcherGetQueue::class.'@handle');
$d->dispatch('some.event', ['foo', 'bar']);

$fakeQueue->assertPushedOn('some_other_queue', CallQueuedListener::class);
}
}

class TestDispatcherQueuedHandler implements ShouldQueue
Expand All @@ -73,3 +89,18 @@ public function handle()
//
}
}

class TestDispatcherGetQueue implements ShouldQueue
{
public $queue = 'my_queue';

public function handle()
{
//
}

public function getQueue()
{
return 'some_other_queue';
}
}

0 comments on commit 097caee

Please sign in to comment.