SearchPreprocessLangcodeTest.php in Drupal 10
File
core/modules/search/tests/src/Functional/SearchPreprocessLangcodeTest.php
View source
<?php
namespace Drupal\Tests\search\Functional;
use Drupal\Tests\BrowserTestBase;
class SearchPreprocessLangcodeTest extends BrowserTestBase {
protected static $modules = [
'node',
'search',
'search_langcode_test',
];
protected $defaultTheme = 'stark';
protected $node;
protected function setUp() : void {
parent::setUp();
$this
->drupalCreateContentType([
'type' => 'page',
'name' => 'Basic page',
]);
$web_user = $this
->drupalCreateUser([
'create page content',
'edit own page content',
'search content',
'use advanced search',
]);
$this
->drupalLogin($web_user);
}
public function testPreprocessLangcode() {
$this->node = $this
->drupalCreateNode([
'body' => [
[],
],
'langcode' => 'en',
]);
$this->container
->get('plugin.manager.search')
->createInstance('node_search')
->updateIndex();
$edit = [
'or' => 'Additional text',
];
$this
->drupalGet('search/node');
$this
->submitForm($edit, 'edit-submit--2');
$this
->assertSession()
->pageTextContains('Langcode Preprocess Test: en');
}
public function testPreprocessStemming() {
$this->node = $this
->drupalCreateNode([
'title' => 'we are testing',
'body' => [
[],
],
'langcode' => 'en',
]);
$this->container
->get('plugin.manager.search')
->createInstance('node_search')
->updateIndex();
$edit = [
'or' => 'testing',
];
$this
->drupalGet('search/node');
$this
->submitForm($edit, 'edit-submit--2');
$this
->assertSession()
->pageTextContains('Search results');
$this
->assertSession()
->pageTextContains('we are testing');
$edit = [
'or' => 'test',
];
$this
->drupalGet('search/node');
$this
->submitForm($edit, 'edit-submit--2');
$this
->assertSession()
->pageTextContains('Search results');
$this
->assertSession()
->pageTextContains('we are testing');
}
}