/** * @test */ public function it_should_wrap_amqp_exception() { $message = new MessageCommand('message', 'key'); $this->exchange->shouldReceive('publish')->once()->andThrow(\AMQPExchangeException::class); try { $this->publisher->publish($message); $this->fail('A exception should have been throw by exchange::publish'); } catch (FailedToPublishException $e) { $this->assertInstanceOf(\AMQPExchangeException::class, $e->getPrevious(), 'Expected the previous exception to be the throw to be a \\AMQPExchangeException'); $this->assertEquals($message, $e->getTacticianMessage()); return; } catch (\Exception $e) { $this->fail(sprintf('A exception of type %s was expected but got %s', \AMQPExchangeException::class, get_class($e))); } }