public function testApiSend_RejectsPromiseOnFailure()
{
$req = $this->createRequest($name = 'name', $mssg = 'secret');
$result = '';
$channel = $this->getProtectedProperty($req, 'channel');
$channel->expects($this->once())->method('send')->will($this->returnCallback(function ($name, $message, $mode, $success, $failure, $abort, $timeout) {
$failure('error');
}));
$callable = $this->createCallableMock();
$callable->expects($this->once())->method('__invoke')->will($this->returnCallback(function ($value) use(&$result) {
$result = $value;
}));
$promise = new Promise();
$promise->then(null, $callable);
$this->callProtectedMethod($req, 'send', [$promise]);
$this->assertSame('error', $result);
}