/**
  * Test Response sets
  */
 public function testSetGetResponse()
 {
     $response = new Response();
     $exception = new BadResponseException();
     $exception->setResponse($response);
     $this->assertEquals($response, $exception->getResponse());
 }
Ejemplo n.º 2
0
 /**
  * @param string $endpoint
  * @param array $data
  * @return \Psr\Http\Message\ResponseInterface
  * @throws BadResponseException
  */
 protected function apiRequest($endpoint, array $data = [])
 {
     $botToken = "bot" . $this->authenticationToken;
     try {
         return $this->post($this->apiUrl . $botToken . "/" . $endpoint, ["form_params" => $data]);
     } catch (\GuzzleHttp\Exception\BadResponseException $e) {
         $exception = new BadResponseException($e);
         $exception->setResponse($this->entityFromBody($e->getResponse()->getBody(), new Response()));
         throw $exception;
     }
 }