/**
  * Tests adapter page 2 content.
  */
 public function testGetSlicePage2()
 {
     $this->service->expects($this->any())->method('execute')->with($this->search)->will($this->returnValue(['hits' => ['total' => 4, 'hits' => [['_source' => ['id' => 'd3', 'field1' => 'value1']], ['_source' => ['id' => 'd4', 'field1' => 'value1']]]]]));
     $this->specify('getting page 2 results', function () {
         verify($this->adapter->getSlice(2, 2))->equals([['_source' => ['id' => 'd3', 'field1' => 'value1']], ['_source' => ['id' => 'd4', 'field1' => 'value1']]]);
         verify($this->adapter->getNbResults())->equals(4);
     });
 }
 /**
  * Tests building sort from string.
  */
 public function testBuildSortFromString()
 {
     $this->specify('builds sorts from simple sort string', function () {
         $sorts = $this->service->createSortStringParser()->buildSortFromString('_score;_doc');
         verify($sorts)->notEmpty();
         verify($sorts[0]->toArray())->equals('_score');
         verify($sorts[1]->toArray())->equals('_doc');
     });
     $this->specify('builds sorts from complex sort string', function () {
         $sorts = $this->service->createSortStringParser()->buildSortFromString('field1:asc;field2:desc:sum;_score');
         verify($sorts)->notEmpty();
         verify($sorts[0]->toArray())->equals(['field1' => ['order' => 'asc']]);
         verify($sorts[1]->toArray())->equals(['field2' => ['order' => 'desc', 'mode' => 'sum']]);
         verify($sorts[2]->toArray())->equals('_score');
     });
 }
 /**
  * Tests the indices method.
  */
 public function testMethodIndices()
 {
     $output = [];
     $this->client->expects($this->any())->method('indices')->will($this->returnValue($output));
     $this->specify('method indices is ran', function () use($output) {
         verify($this->service->indices())->equals($output);
     });
 }
 /**
  * Register bindings.
  */
 protected function registerBindings()
 {
     /** @noinspection PhpUndefinedMethodInspection */
     $config = $this->app['config']->get('elasticsearch', []);
     $this->app->singleton(ElasticsearchServiceContract::class, function () use($config) {
         $elasticsearchService = new ElasticsearchService(ClientBuilder::fromConfig($config));
         if (isset($config[self::CONFIG_KEY]['settings'])) {
             $elasticsearchService->setSettings($config[self::CONFIG_KEY]['settings']);
         }
         return $elasticsearchService;
     });
 }
 /**
  * @inheritdoc
  */
 public function _before()
 {
     $this->service = new \Nord\Lumen\Elasticsearch\ElasticsearchService(\Elasticsearch\ClientBuilder::fromConfig([]));
     $this->sortBuilder = $this->service->createSortBuilder();
 }