public function testMakeIfResponseNotSuccessful() { $response = (new Response())->withStatus(400); $exception = NotSuccessfulResponseHttpMessageSendingException::makeIfResponseNotSuccessful($response, NotSuccessfulResponseHttpMessageSendingException::MODE_CLIENT); $this->assertInstanceOf('Subscribo\\Omnipay\\Shared\\Exception\\NotSuccessfulResponseHttpMessageSendingException', $exception); $this->assertSame($response, $exception->getResponse()); }
/** * @param RequestInterface $request * @param bool|string $throwExceptionMode - true for any non-success response, 'client' for client errors only, 'server' for server errors only * @return ResponseInterface * @throws TransportErrorHttpMessageSendingException * @throws ClientErrorResponseHttpMessageSendingException * @throws ServerErrorResponseHttpMessageSendingException * @throws NotSuccessfulResponseHttpMessageSendingException */ protected function sendHttpMessage(RequestInterface $request, $throwExceptionMode = false) { try { $client = $this->httpClient; $adapter = new Guzzle3HttpAdapter($client); $response = $adapter->sendRequest($request); } catch (Exception $e) { throw new TransportErrorHttpMessageSendingException($e->getMessage(), $e->getCode(), $e); } NotSuccessfulResponseHttpMessageSendingException::makeIfResponseNotSuccessful($response, $throwExceptionMode, true); return $response; }