本文整理汇总了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());
}