protected function setUp() { $this->logger = $this->prophesize(LoggerInterface::class); $this->handler = new LogHandler($this->logger->reveal()); $this->consumerContainer = $this->prophesize(ConsumerContainer::class); $this->consumerContainer->getMessageClass()->willReturn(self::MESSAGE_CLASS); }
/** * @param ConsumerContainer $consumerContainer * @param AMQPMessage $message * * @throws ConsumerContainerException * @return mixed|null */ private function invoke(ConsumerContainer $consumerContainer, AMQPMessage $message) { $payload = $this->serializer->deserialize($message->body, $consumerContainer->getMessageClass(), 'json'); try { $result = $consumerContainer->invoke($payload); } catch (Exception $e) { $containerException = new ConsumerContainerException($consumerContainer, $message, $payload, $e); if ($this->errorHandlers->isEmpty()) { throw $containerException; } $this->errorHandlers->map(function (ErrorHandlerInterface $handler) use($containerException) { $handler->handle($containerException); }); return null; } return $result; }