You are here

public function SearchApiElasticsearchElasticaTest::testIndexItems in Search API Elasticsearch 7

testIndexItems

@dataProvider transportProvider @access public

Return value

void

File

modules/elastica/tests/phpunit/SearchApiElasticsearchElasticaTest.php, line 184
Contains tests for SearchApiElasticsearchElastica.

Class

SearchApiElasticsearchElasticaTest
@file Contains tests for SearchApiElasticsearchElastica.

Code

public function testIndexItems($transport) {
  $this->_client
    ->setTransport($transport);
  $result_set = $this->_client
    ->getElasticaType($this->_index)
    ->search('batman');
  $this
    ->assertEquals(1, $result_set
    ->count());
  $count = $this->_client
    ->getElasticaType($this->_index)
    ->count('batman');
  $this
    ->assertEquals(1, $count);
  $result = $result_set
    ->current();
  $this
    ->assertNotFalse($result);
  $this
    ->assertEquals(1, $result
    ->getId());
  $data = $result
    ->getData();
  $this
    ->assertEquals('batman', $data['title']);
  $this->_query
    ->fields(array(
    'title',
  ));
  $this->_query
    ->keys('batman');
  $result_set = $this->_client
    ->search($this->_query);
  $this
    ->assertEquals(1, $result_set['result count']);
  $this
    ->assertEmpty($this->_client
    ->indexItems($this->_index, array()));
}