예제 #1
0
 /**
  * @covers \jones\novaposhta\http\Client::execute
  * @expectedException \jones\novaposhta\http\ClientException
  * @expectedExceptionMessage Exception thrown by Guzzle client and has response
  */
 public function testExecuteWithClientExceptionAndHasResponse()
 {
     $message = 'Exception thrown by Guzzle client and has response';
     /** @var \GuzzleHttp\Psr7\Request $request */
     $request = $this->getMockBuilder(GuzzleRequest::class)->disableOriginalConstructor()->getMock();
     $exception = new ClientException($message, $request, $this->response);
     $this->guzzleClient->expects(static::once())->method('post')->willThrowException($exception);
     $this->response->expects(static::never())->method('getBody');
     $this->client->execute($this->request, ConverterInterface::FORMAT_XML, Request::API_URL_XML);
 }
예제 #2
0
 /**
  * @covers \jones\novaposhta\request\Request::getUrl
  */
 public function testGetJsonUrl()
 {
     $this->request = Yii::createObject(Request::class, [new JsonConverter(), $this->httpClientFactory, self::API_KEY]);
     $this->httpClient->expects(static::once())->method('execute')->willReturn(json_encode(['success' => 'true', 'data' => [['Description' => 'Kiev']], 'errors', 'warnings', 'info']));
     $this->request->execute();
 }