You are here

public function SearchTokenizerTest::testNoTokenizer in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/search/tests/src/Kernel/SearchTokenizerTest.php \Drupal\Tests\search\Kernel\SearchTokenizerTest::testNoTokenizer()
  2. 9 core/modules/search/tests/src/Kernel/SearchTokenizerTest.php \Drupal\Tests\search\Kernel\SearchTokenizerTest::testNoTokenizer()

Verifies that strings of non-CJK characters are not tokenized.

This is just a sanity check - it verifies that strings of letters are not tokenized.

File

core/modules/search/tests/src/Kernel/SearchTokenizerTest.php, line 113

Class

SearchTokenizerTest
Tests that CJK tokenizer works as intended.

Namespace

Drupal\Tests\search\Kernel

Code

public function testNoTokenizer() {

  // Set the minimum word size to 1 (to split all CJK characters) and make
  // sure CJK tokenizing is turned on.
  $this
    ->config('search.settings')
    ->set('index.minimum_word_size', 1)
    ->set('index.overlap_cjk', TRUE)
    ->save();
  $letters = 'abcdefghijklmnopqrstuvwxyz';
  $text_processor = \Drupal::service('search.text_processor');
  assert($text_processor instanceof SearchTextProcessorInterface);
  $out = trim($text_processor
    ->analyze($letters));
  $this
    ->assertEquals($letters, $out, 'Letters are not CJK tokenized');
}