<?php
namespace Drupal\search\Tests;
class SearchPreprocessLangcodeTest extends SearchTestBase {
public static $modules = array(
'search_langcode_test',
);
public static function getInfo() {
return array(
'name' => 'Search preprocess langcode',
'description' => 'Check that the hook_search_preprocess passes the correct langcode from the entity.',
'group' => 'Search',
);
}
function setUp() {
parent::setUp();
$web_user = $this
->drupalCreateUser(array(
'create page content',
'edit own page content',
'search content',
'use advanced search',
));
$this
->drupalLogin($web_user);
}
function testPreprocessLangcode() {
$node = $this
->drupalCreateNode(array(
'body' => array(
'en' => array(
array(),
),
),
'langcode' => 'en',
));
node_update_index();
search_update_totals();
$edit = array(
'or' => $node
->label(),
);
$this
->drupalPost('search/node', $edit, t('Advanced search'));
$this
->assertText('Langcode Preprocess Test: en');
}
function testPreprocessStemming() {
$node = $this
->drupalCreateNode(array(
'title' => 'we are testing',
'body' => array(
'en' => array(
array(),
),
),
'langcode' => 'en',
));
node_update_index();
search_update_totals();
$edit = array(
'or' => 'testing',
);
$this
->drupalPost('search/node', $edit, t('Advanced search'));
$this
->assertText('Search results');
$this
->assertText('we are testing');
$edit = array(
'or' => 'test',
);
$this
->drupalPost('search/node', $edit, t('Advanced search'));
$this
->assertText('Search results');
$this
->assertText('we are testing');
}
}