You are here

function SearchMatchTest::_setup in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/search/src/Tests/SearchMatchTest.php \Drupal\search\Tests\SearchMatchTest::_setup()

Set up a small index of items to test against.

1 call to SearchMatchTest::_setup()
SearchMatchTest::testMatching in core/modules/search/src/Tests/SearchMatchTest.php
Test search indexing.

File

core/modules/search/src/Tests/SearchMatchTest.php, line 53
Contains \Drupal\search\Tests\SearchMatchTest.

Class

SearchMatchTest
Indexes content and queries it.

Namespace

Drupal\search\Tests

Code

function _setup() {
  $this
    ->config('search.settings')
    ->set('index.minimum_word_size', 3)
    ->save();
  for ($i = 1; $i <= 7; ++$i) {
    search_index(SEARCH_TYPE, $i, LanguageInterface::LANGCODE_NOT_SPECIFIED, $this
      ->getText($i));
  }
  for ($i = 1; $i <= 5; ++$i) {
    search_index(SEARCH_TYPE_2, $i + 7, LanguageInterface::LANGCODE_NOT_SPECIFIED, $this
      ->getText2($i));
  }

  // No getText builder function for Japanese text; just a simple array.
  foreach (array(
    13 => '以呂波耳・ほへとち。リヌルヲ。',
    14 => 'ドルーパルが大好きよ!',
    15 => 'コーヒーとケーキ',
  ) as $i => $jpn) {
    search_index(SEARCH_TYPE_JPN, $i, LanguageInterface::LANGCODE_NOT_SPECIFIED, $jpn);
  }
  search_update_totals();
}