Tests that hook_search_preprocess() returns the correct langcode.
function testPreprocessLangcode() {
// Create a node.
$node = $this
->drupalCreateNode(array(
'body' => array(
array(),
),
'langcode' => 'en',
));
// First update the index. This does the initial processing.
node_update_index();
// Then, run the shutdown function. Testing is a unique case where indexing
// and searching has to happen in the same request, so running the shutdown
// function manually is needed to finish the indexing process.
search_update_totals();
// Search for the title of the node with a POST query.
$edit = array(
'or' => $node
->label(),
);
$this
->drupalPost('search/node', $edit, t('Advanced search'));
// Checks if the langcode has been passed by hook_search_preprocess().
$this
->assertText('Langcode Preprocess Test: en');
}