本文整理匯總了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);
}
示例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);
}
示例3: testOptions
public function testOptions()
{
$this->guzzleClient->method('options')->willReturn(new Response(1337));
$this->assertEquals(1337, $this->client->options('http://localhost/', [])->getStatusCode());
}