/** * @test */ public function it_should_reject_a_envelope_when_there_is_a_exception() { $middleware = new ConsumeMiddleware(false); $this->queue->shouldNotReceive('ack')->with('tag'); $this->queue->shouldReceive('reject')->once()->with('tag', AMQP_NOPARAM); $this->envelope->shouldReceive('getDeliveryTag')->withNoArgs()->andReturn('tag'); $this->setExpectedException(\RuntimeException::class, 'The queue should reject the message now'); $middleware->execute($this->command, function () { throw new \RuntimeException('The queue should reject the message now'); }); }