I'm trying to test my process of handling some data via messenger in Symfony.
I try the following:
At first, I define my worker.
$event_dispatcher = $this->getContainer()->get(EventDispatcherInterface::class);
$logger = $this->getContainer()->get(LoggerInterface::class);
$message_bus = $this->getContainer()->get(MessageBusInterface::class);
$transport = $this->getContainer()->get("messenger.transport.async");
$worker = new Worker([$transport], $message_bus, $event_dispatcher, $logger);
Then after this, some code runs that sends a message to the messenger. I tested this code and this works fine. With dumping $transport->get() I see that my messages have been successfully sending to the worker and database.
Now at the end of my unit test, I run the worker via $worker->run(). Since the messenger only handles a couple of actions/queries it should only take a little bit for it to finish. But it looks like it is just idling there. I call $worker->stop() directly after $worker->run() but it does not reach there.