本文整理汇总了PHP中GuzzleHttp\ClientInterface::method方法的典型用法代码示例。如果您正苦于以下问题:PHP ClientInterface::method方法的具体用法?PHP ClientInterface::method怎么用?PHP ClientInterface::method使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GuzzleHttp\ClientInterface
的用法示例。
在下文中一共展示了ClientInterface::method方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetUrlBodyError
/**
* @expectedException \RuntimeException
*/
public function testGetUrlBodyError()
{
$guzzleResponse = $this->getMock('\\Psr\\Http\\Message\\ResponseInterface');
$guzzleResponse->method('getStatusCode')->will($this->returnValue(404));
$guzzleResponse->method('getBody')->will($this->returnValue('mock'));
$this->httpClient->method('request')->will($this->returnValue($guzzleResponse));
$this->client->getUrlBody('http://google.com/notfound');
}
示例2: testExceptionMessageLoggedOnDownload
/**
* Test Guzzle with exception logged
*/
public function testExceptionMessageLoggedOnDownload()
{
$message = uniqid();
$exception = new Exception($message);
$this->guzzle->method('send')->will($this->throwException($exception));
$logger = $this->getMock('\\Psr\\Log\\LoggerInterface');
$spy = $this->any();
$logger->expects($spy)->method('warning');
$this->fixture->setLogger($logger);
$this->fixture->download();
$invocationList = $spy->getInvocations();
$firstWarning = $invocationList[0]->parameters[0];
$secondWarning = $invocationList[1]->parameters[0];
$this->assertEquals('Client response was not a success', $firstWarning);
$this->assertEquals('0: `' . $message . '`', $secondWarning);
}