public function SearchPreprocessLangcodeTest::testPreprocessLangcode in Drupal 8
Same name and namespace in other branches
- 9 core/modules/search/tests/src/Functional/SearchPreprocessLangcodeTest.php \Drupal\Tests\search\Functional\SearchPreprocessLangcodeTest::testPreprocessLangcode()
Tests that hook_search_preprocess() returns the correct langcode.
File
- core/
modules/ search/ tests/ src/ Functional/ SearchPreprocessLangcodeTest.php, line 48
Class
- SearchPreprocessLangcodeTest
- Tests that the search preprocessing uses the correct language code.
Namespace
Drupal\Tests\search\FunctionalCode
public function testPreprocessLangcode() {
// Create a node.
$this->node = $this
->drupalCreateNode([
'body' => [
[],
],
'langcode' => 'en',
]);
// First update the index. This does the initial processing.
$this->container
->get('plugin.manager.search')
->createInstance('node_search')
->updateIndex();
// Search for the additional text that is added by the preprocess
// function. If you search for text that is in the node, preprocess is
// not invoked on the node during the search excerpt generation.
$edit = [
'or' => 'Additional text',
];
$this
->drupalPostForm('search/node', $edit, 'edit-submit--2');
// Checks if the langcode message has been set by hook_search_preprocess().
$this
->assertText('Langcode Preprocess Test: en');
}