/**
  * @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'));
 }
Ejemplo n.º 2
0
 /**
  * @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));
 }
Ejemplo n.º 3
0
 /** @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]);
 }