public function testConsuming()
 {
     $message = new Message('{"a": 10, "b": 15}', ['headers' => ['to' => 'phpunit']]);
     $queue = $this->channel->queue()->define(QueueInterface::FLAG_AUTO_DELETE);
     $this->channel->publish($message, '', $queue);
     $this->handler->expects($this->once())->method('handle')->willReturnCallback(function (Delivery $message) {
         $message->cancel();
     });
     $this->consumer->consume($queue);
 }
 public function testHandleRPCException()
 {
     $this->endpoint->expects($this->once())->method('call')->willThrowException(new \Exception('foo', 129));
     $request = new Delivery($this->channel, 'cons', 1, false, '', 'boo', '{}', ['reply-to' => 'foo']);
     $reply = $this->handler->handle($request);
     $this->assertNotNull($reply);
     $headers = $reply->getHeaders();
     $this->assertArrayHasKey('x-error', $headers);
     $this->assertEquals('foo', $headers['x-error']);
     $this->assertArrayHasKey('x-error-code', $headers);
     $this->assertEquals(129, $headers['x-error-code']);
 }