本文整理匯總了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);
}