You are here

public function SearchApiElasticsearchElasticaTest::testDeleteMultipleItems in Search API Elasticsearch 7

testDeleteMultipleItems

@dataProvider transportProvider @access public

Return value

void

File

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

Class

SearchApiElasticsearchElasticaTest
@file Contains tests for SearchApiElasticsearchElastica.

Code

public function testDeleteMultipleItems($transport) {
  $this->_client
    ->setTransport($transport);
  $result_set = $this->_client
    ->getElasticaType($this->_index)
    ->search('batman');
  $this
    ->assertEquals(1, $result_set
    ->count());
  $result = $result_set
    ->current();
  $this
    ->assertNotFalse($result);
  $this
    ->assertEquals(1, $result
    ->getId());
  $result_set = $this->_client
    ->getElasticaType($this->_index)
    ->search('robin');
  $this
    ->assertEquals(1, $result_set
    ->count());
  $result = $result_set
    ->current();
  $this
    ->assertNotFalse($result);
  $this
    ->assertEquals(2, $result
    ->getId());
  $this->_client
    ->deleteItems(array(
    '1',
    '2',
  ), $this->_index);
  $this->_client
    ->getElasticaIndex($this->_index)
    ->refresh();
  $result_set = $this->_client
    ->getElasticaType($this->_index)
    ->search('batman');
  $this
    ->assertEquals(0, $result_set
    ->count());
  $result_set = $this->_client
    ->getElasticaType($this->_index)
    ->search('robin');
  $this
    ->assertEquals(0, $result_set
    ->count());
  $result_set = $this->_client
    ->getElasticaType($this->_index)
    ->search('catwoman');
  $this
    ->assertEquals(1, $result_set
    ->count());
}