本文整理匯總了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);
}