/** * performs sending the request * * @param RequestInterface $request * * @throws ClientException * @throws RequestException * @return ResponseInterface * @author Daniel Wendlandt */ public function send(RequestInterface $request) { $timeTaken = microtime(true); try { $response = $this->client->send($request); if (null !== $this->dataCollector) { $this->dataCollector->add(ElasticsearchDataCollector::TYPE_SUCCESS, (microtime(true) - $timeTaken) * 1000, $request, $response); } return $response; } catch (ClientException $exception) { if (null !== $this->dataCollector) { $this->dataCollector->add(ElasticsearchDataCollector::TYPE_ERROR, (microtime(true) - $timeTaken) * 1000, $request); } throw $exception; } }
public function testCollect() { $request = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\Request')->getMock(); $response = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\Response')->getMock(); $this->dataCollector->collect($request, $response); }