function SearchTextProcessorTest::testSearchTextProcessorPunctuation
Same name in other branches
- 9 core/modules/search/tests/src/Kernel/SearchTextProcessorTest.php \Drupal\Tests\search\Kernel\SearchTextProcessorTest::testSearchTextProcessorPunctuation()
- 11.x core/modules/search/tests/src/Kernel/SearchTextProcessorTest.php \Drupal\Tests\search\Kernel\SearchTextProcessorTest::testSearchTextProcessorPunctuation()
Tests that text analysis does the right thing with punctuation.
File
-
core/
modules/ search/ tests/ src/ Kernel/ SearchTextProcessorTest.php, line 82
Class
- SearchTextProcessorTest
- Test search text preprocessing functionality.
Namespace
Drupal\Tests\search\KernelCode
public function testSearchTextProcessorPunctuation() : void {
$cases = [
[
'20.03/94-28,876',
'20039428876',
'Punctuation removed from numbers',
],
[
'great...drupal--module',
'great drupal module',
'Multiple dot and dashes are word boundaries',
],
[
'very_great-drupal.module',
'verygreatdrupalmodule',
'Single dot, dash, underscore are removed',
],
[
'regular,punctuation;word',
'regular punctuation word',
'Punctuation is a word boundary',
],
];
$text_processor = \Drupal::service('search.text_processor');
assert($text_processor instanceof SearchTextProcessorInterface);
foreach ($cases as $case) {
$out = trim($text_processor->analyze($case[0]));
$this->assertEquals($case[1], $out, $case[2]);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.