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


PHP Client::getLastResponse方法代码示例

本文整理汇总了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);
 }
开发者ID:ngitimfoyo,项目名称:Nyari-AppPHP,代码行数:30,代码来源:ElasticSearchHandlerTest.php

示例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);
 }
开发者ID:viz,项目名称:wordpress-fantastic-elasticsearch,代码行数:12,代码来源:ClientTest.php


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