public function testApiSend_SendsMessageAsException_OnFailure()
{
$protocol = $this->createProtocol();
$rep = $this->createResponse($protocol, $ex = new Exception('secret'));
$promise = new Promise();
$channel = $this->getProtectedProperty($rep, 'channel');
$channel->expects($this->once())->method('send')->will($this->returnCallback(function ($origin, ProtocolInterface $answer, $mode) use($ex) {
$this->assertSame('secret', $answer->getMessage());
$this->assertSame(get_class($ex), $answer->getException());
$this->assertSame(Channel::MODE_BUFFER_ONLINE, $mode);
}));
$this->callProtectedMethod($rep, 'send', [$promise]);
}