当前位置: 首页>>代码示例>>PHP>>正文


PHP Response::setInfo方法代码示例

本文整理汇总了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'));
 }
开发者ID:aptoma,项目名称:silex-extras,代码行数:15,代码来源:MonologGuzzleLogAdapterTest.php

示例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));
 }
开发者ID:tableau-mkt,项目名称:elomentary,代码行数:17,代码来源:HttpClientTest.php

示例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]);
 }
开发者ID:karllhughes,项目名称:clearbit-php,代码行数:14,代码来源:ClientTest.php


注:本文中的Guzzle\Http\Message\Response::setInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。