本文整理汇总了PHP中Elastica\Client::getLastResponse方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::getLastResponse方法的具体用法?PHP Client::getLastResponse怎么用?PHP Client::getLastResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Elastica\Client
的用法示例。
在下文中一共展示了Client::getLastResponse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testHandleIntegration
/**
* Integration test using localhost Elastic Search server
*
* @covers Monolog\Handler\ElasticSearchHandler::__construct
* @covers Monolog\Handler\ElasticSearchHandler::handleBatch
* @covers Monolog\Handler\ElasticSearchHandler::bulkSend
* @covers Monolog\Handler\ElasticSearchHandler::getDefaultFormatter
*/
public function testHandleIntegration()
{
$msg = array('level' => Logger::ERROR, 'level_name' => 'ERROR', 'channel' => 'meh', 'context' => array('foo' => 7, 'bar', 'class' => new \stdClass()), 'datetime' => new \DateTime("@0"), 'extra' => array(), 'message' => 'log');
$expected = $msg;
$expected['datetime'] = $msg['datetime']->format(\DateTime::ISO8601);
$expected['context'] = array('class' => '[object] (stdClass: {})', 'foo' => 7, 0 => 'bar');
$client = new Client();
$handler = new ElasticSearchHandler($client, $this->options);
try {
$handler->handleBatch(array($msg));
} catch (\RuntimeException $e) {
$this->markTestSkipped("Cannot connect to Elastic Search server on localhost");
}
// check document id from ES server response
$documentId = $this->getCreatedDocId($client->getLastResponse());
$this->assertNotEmpty($documentId, 'No elastic document id received');
// retrieve document source from ES and validate
$document = $this->getDocSourceFromElastic($client, $this->options['index'], $this->options['type'], $documentId);
$this->assertEquals($expected, $document);
// remove test index from ES
$client->request("/{$this->options['index']}", Request::DELETE);
}
示例2: testLastRequestResponse
public function testLastRequestResponse()
{
$client = new Client();
$response = $client->request('_status');
$this->assertInstanceOf('Elastica\\Response', $response);
$lastRequest = $client->getLastRequest();
$this->assertInstanceOf('Elastica\\Request', $lastRequest);
$this->assertEquals('_status', $lastRequest->getPath());
$lastResponse = $client->getLastResponse();
$this->assertInstanceOf('Elastica\\Response', $lastResponse);
$this->assertSame($response, $lastResponse);
}