// their own lines). So the even-numbered lines should simplify to nothing,
// and the odd-numbered lines we need to split into shorter chunks and
// verify that text processing doesn't lose any characters.
$input =
file_get_contents($this->root . '/core/modules/search/tests/UnicodeTest.txt'
);
$basestrings =
explode(chr(10
),
$input);
$strings =
[];
$text_processor = \Drupal::
service('search.text_processor'
);
assert($text_processor instanceof SearchTextProcessorInterface
);
foreach ($basestrings as $key =>
$string) { if ($key % 2
) { // Even line - should simplify down to a space.
$simplified =
$text_processor->
analyze($string);
$this->
assertSame(' ',
$simplified, "Line {
$key} is excluded from the index"
);
} else { // Odd line, should be word characters.
// Split this into 30-character chunks, so we don't run into limits of
// truncation in
// \Drupal\search\SearchTextProcessorInterface::analyze().
$start = 0;
while ($start <
mb_strlen($string)) { $newstr =
mb_substr($string,
$start, 30
);
// Special case: leading zeros are removed from numeric strings,