/** * Tests the basic.return if a message cannot be routed. * * @test */ public function routeToUnboundExchangeShouldBasicReturn() { $this->admin->declareExchange(new Tx_Amqp_Messaging_DirectExchange(self::TEST_EXCHANGE, FALSE, TRUE)); $this->service->setMandatory(TRUE); $self = $this; $messageBody = 'basic.return with no binding to destination queue'; $this->service->send(new \PhpAmqpLib\Message\AMQPMessage($messageBody), self::TEST_EXCHANGE); $this->service->handleReturn(function (Tx_Amqp_Messaging_UndeliverableMessage $message) use($self, $messageBody) { $self->assertEquals($messageBody, $message->getMessage()->body); Tx_Amqp_Messaging_AMQPUtils::throwStopException(); }); $this->admin->deleteExchange(self::TEST_EXCHANGE); }