當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Client::method方法代碼示例

本文整理匯總了PHP中GuzzleHttp\Client::method方法的典型用法代碼示例。如果您正苦於以下問題:PHP Client::method方法的具體用法?PHP Client::method怎麽用?PHP Client::method使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在GuzzleHttp\Client的用法示例。


在下文中一共展示了Client::method方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testSendPostRequestWorksWithoutLogger

 public function testSendPostRequestWorksWithoutLogger()
 {
     $this->loggerMock = null;
     $this->httpClientMock->method('createRequest')->willReturn(new \GuzzleHttp\Message\Request('POST', 'someUrl'));
     $this->httpClientMock->method('send')->willReturn($this->createFutureResponse(200, '{"someData":8}'));
     $requestMaker = $this->createRequestMaker();
     $requestMaker->sendPostRequest('somerUrl');
     $this->assertTrue(true);
 }
開發者ID:pepakriz,項目名稱:zbozi-api-php-library,代碼行數:9,代碼來源:RequestMakerTest.php

示例2: prepareGuzzleMockResponse

 /**
  * Prepares guzzle to respond to a method with a specific mocked response
  *
  * @param string $path          relative path, excluding base url
  * @param mixed  $response
  * @param string $method        POST/GET/etc
  * @param int    $statusCode
  * @param string $reasonPhrase
  */
 protected function prepareGuzzleMockResponse($path, $response, $method = 'POST', $statusCode = 200, $reasonPhrase = 'OK')
 {
     $responseMock = $this->getMockBuilder(Response::class)->getMock();
     $responseBodyMock = $this->getMockBuilder(StreamInterface::class)->getMock();
     $responseBodyMock->method('getContents')->willReturn(json_encode($response));
     $responseMock->method('getStatusCode')->willReturn($statusCode);
     $responseMock->method('getReasonPhrase')->willReturn($reasonPhrase);
     $responseMock->method('getHeaders')->willReturn([]);
     $responseMock->method('getBody')->willReturn($responseBodyMock);
     $this->guzzleMock->method('request')->with($method, rtrim(static::BASE_API_URL, '/') . '/' . $path)->willReturn($responseMock);
 }
開發者ID:czim,項目名稱:van-domburg-api-client,代碼行數:20,代碼來源:ApiClientTest.php

示例3: testOptions

 public function testOptions()
 {
     $this->guzzleClient->method('options')->willReturn(new Response(1337));
     $this->assertEquals(1337, $this->client->options('http://localhost/', [])->getStatusCode());
 }
開發者ID:rchicoli,項目名稱:owncloud-core,代碼行數:5,代碼來源:ClientTest.php


注:本文中的GuzzleHttp\Client::method方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。