You are here

public function SearchApiSolrTest::searchSuccess in Search API Solr 4.x

Same name and namespace in other branches
  1. 8.3 tests/src/Kernel/SearchApiSolrTest.php \Drupal\Tests\search_api_solr\Kernel\SearchApiSolrTest::searchSuccess()
  2. 8.2 tests/src/Kernel/SearchApiSolrTest.php \Drupal\Tests\search_api_solr\Kernel\SearchApiSolrTest::searchSuccess()

File

tests/src/Kernel/SearchApiSolrTest.php, line 190

Class

SearchApiSolrTest
Tests index and search capabilities using the Solr search backend.

Namespace

Drupal\Tests\search_api_solr\Kernel

Code

public function searchSuccess() {
  parent::searchSuccess();
  $parse_mode_manager = \Drupal::service('plugin.manager.search_api.parse_mode');
  $parse_mode_direct = $parse_mode_manager
    ->createInstance('direct');
  $results = $this
    ->buildSearch('+test +case', [], [
    'body',
  ])
    ->setParseMode($parse_mode_direct)
    ->execute();
  $this
    ->assertResults([
    1,
    2,
    3,
  ], $results, 'Parse mode direct with AND');
  $results = $this
    ->buildSearch('test -case', [], [
    'body',
  ])
    ->setParseMode($parse_mode_direct)
    ->execute();
  $this
    ->assertResults([
    4,
  ], $results, 'Parse mode direct with NOT');
  $results = $this
    ->buildSearch('"test case"', [], [
    'body',
  ])
    ->setParseMode($parse_mode_direct)
    ->execute();
  $this
    ->assertResults([
    1,
    2,
  ], $results, 'Parse mode direct with phrase');
}