function SearchMatchTest::_setup
Same name in other branches
- 9 core/modules/search/tests/src/Kernel/SearchMatchTest.php \Drupal\Tests\search\Kernel\SearchMatchTest::_setup()
- 8.9.x core/modules/search/tests/src/Kernel/SearchMatchTest.php \Drupal\Tests\search\Kernel\SearchMatchTest::_setup()
- 10 core/modules/search/tests/src/Kernel/SearchMatchTest.php \Drupal\Tests\search\Kernel\SearchMatchTest::_setup()
Set up a small index of items to test against.
1 call to SearchMatchTest::_setup()
- SearchMatchTest::testMatching in core/
modules/ search/ tests/ src/ Kernel/ SearchMatchTest.php - Tests search indexing.
File
-
core/
modules/ search/ tests/ src/ Kernel/ SearchMatchTest.php, line 53
Class
- SearchMatchTest
- Indexes content and queries it.
Namespace
Drupal\Tests\search\KernelCode
public function _setup() : void {
$this->config('search.settings')
->set('index.minimum_word_size', 3)
->save();
$search_index = \Drupal::service('search.index');
assert($search_index instanceof SearchIndexInterface);
for ($i = 1; $i <= 7; ++$i) {
$search_index->index(static::SEARCH_TYPE, $i, LanguageInterface::LANGCODE_NOT_SPECIFIED, $this->getText($i));
}
for ($i = 1; $i <= 5; ++$i) {
$search_index->index(static::SEARCH_TYPE_2, $i + 7, LanguageInterface::LANGCODE_NOT_SPECIFIED, $this->getText2($i));
}
// No getText builder function for Japanese text; just a simple array.
foreach ([
13 => '以呂波耳・ほへとち。リヌルヲ。',
14 => 'ドルーパルが大好きよ!',
15 => 'コーヒーとケーキ',
] as $i => $jpn) {
$search_index->index(static::SEARCH_TYPE_JPN, $i, LanguageInterface::LANGCODE_NOT_SPECIFIED, $jpn);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.