public function test_send_calls_adapter_send()
 {
     $this->adapter->expects($this->once())->method('send')->with($this->message)->will($this->returnValue('response text'));
     $conn = new Connection($this->adapter);
     $res = $conn->send($this->message);
     $this->assertInternalType('string', $res);
 }
Пример #2
0
 /**
  * @param AbstractMessage $message
  * @return Response
  * @throws AdapterException
  * @throws CurlException
  * @throws FailedRequestException
  */
 public function sendMessage(AbstractMessage $message)
 {
     try {
         $this->logger->info('Sending Message');
         $message->setMessageNumber($this->messageNumber);
         $message->setDialogId($this->dialogId);
         $result = $this->connection->send($message);
         $this->messageNumber++;
         $response = new Response($result);
         $this->handleResponse($response);
         if (!$response->isSuccess()) {
             $summary = $response->getMessageSummary();
             $ex = new FailedRequestException($summary);
             $this->logger->error($ex->getMessage());
             throw $ex;
         }
         return $response;
     } catch (AdapterException $e) {
         $this->logger->critical($e->getMessage());
         if ($e instanceof CurlException) {
             $this->logger->debug(print_r($e->getCurlInfo(), true));
         }
         throw $e;
     }
 }