本文整理汇总了PHP中Guzzle\Http\Message\Response::setInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::setInfo方法的具体用法?PHP Response::setInfo怎么用?PHP Response::setInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Guzzle\Http\Message\Response
的用法示例。
在下文中一共展示了Response::setInfo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testLogShouldSetLogLevelBasedOnResponseTimes
/**
* @dataProvider responseTimeDataProvider
*/
public function testLogShouldSetLogLevelBasedOnResponseTimes($responseTime, $checkLevelMethod)
{
$logger = new Logger('test');
$handler = new TestHandler();
$logger->pushHandler($handler);
$adapter = new MonologGuzzleLogAdapter($logger);
$response = new Response(200);
$response->setInfo(array('total_time' => $responseTime));
$extras = array('response' => $response, 'request' => new Request('GET', ''));
$adapter->log('debug', LOG_DEBUG, $extras);
$this->assertTrue($handler->{$checkLevelMethod}('debug'));
}
示例2: shouldHandlePagination
/**
* @test
*/
public function shouldHandlePagination()
{
$url = 'http://example.com';
$path = '/some/path';
$body = 'a = b';
$headers = array('c' => 'd');
$response = new Response(200, NULL, json_encode(array('page' => 2, 'pageSize' => 10, 'total' => 30)));
$response->setInfo(array('url' => $url));
$expected_pagination = array('first' => array($url => array('page' => 1, 'count' => 10)), 'last' => array($url => array('page' => 3, 'count' => 10)), 'next' => array($url => array('page' => 3, 'count' => 10)), 'prev' => array($url => array('page' => 1, 'count' => 10)));
$client = $this->getBrowserMock();
$httpClient = new HttpClient(array(), $client);
$httpClient->request($path, $body, 'HEAD', $headers);
$this->assertEquals($expected_pagination, ResponseMediator::getPagination($response));
}
示例3: testGetLogoContentIsNotImageShouldReturnBadResponseException
/** @expectedException Clearbit\Exception\BadResponseException */
public function testGetLogoContentIsNotImageShouldReturnBadResponseException()
{
$domain = 'stripe.com';
$url = 'https://logo.clearbit.com/' . $domain . '?size=128&format=png&greyscale=false';
$info = ['url' => $url, 'content_type' => 'json/text'];
$response = new Response(200);
$response->setInfo($info);
$mock = new MockPlugin();
$mock->addResponse($response);
$client = Client::factory(['api_token' => 'foo']);
$client->addSubscriber($mock);
$result = $client->getLogo(['domain' => $domain]);
}