function SearchTokenizerTest::testNoTokenizer

Same name in other branches
  1. 9 core/modules/search/tests/src/Kernel/SearchTokenizerTest.php \Drupal\Tests\search\Kernel\SearchTokenizerTest::testNoTokenizer()
  2. 8.9.x core/modules/search/tests/src/Kernel/SearchTokenizerTest.php \Drupal\Tests\search\Kernel\SearchTokenizerTest::testNoTokenizer()
  3. 10 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 125

Class

SearchTokenizerTest
Tests that CJK tokenizer works as intended.

Namespace

Drupal\Tests\search\Kernel

Code

public function testNoTokenizer() : void {
    // 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');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.