View source
<?php
namespace Drupal\Tests\search\Functional;
use Drupal\Tests\BrowserTestBase;
class SearchNodeDiacriticsTest extends BrowserTestBase {
protected static $modules = [
'node',
'search',
];
protected $defaultTheme = 'stark';
public $testUser;
protected function setUp() {
parent::setUp();
$this
->drupalCreateContentType([
'type' => 'page',
'name' => 'Basic page',
]);
node_access_rebuild();
$this->testUser = $this
->drupalCreateUser([
'access content',
'search content',
'use advanced search',
'access user profiles',
]);
$this
->drupalLogin($this->testUser);
}
public function testPhraseSearchPunctuation() {
$body_text = 'The Enricþment Center is cómmīŦŧęđ to the well BɆĬŇĜ of æll påŔťıçȉpǎǹţș. ';
$body_text .= 'Also meklēt (see #731298)';
$this
->drupalCreateNode([
'body' => [
[
'value' => $body_text,
],
],
]);
$this->container
->get('plugin.manager.search')
->createInstance('node_search')
->updateIndex();
$this
->refreshVariables();
$edit = [
'keys' => 'meklet',
];
$this
->drupalPostForm('search/node', $edit, t('Search'));
$this
->assertRaw('<strong>meklēt</strong>');
$edit = [
'keys' => 'meklēt',
];
$this
->drupalPostForm('search/node', $edit, t('Search'));
$this
->assertRaw('<strong>meklēt</strong>');
$edit = [
'keys' => 'cómmīŦŧęđ BɆĬŇĜ påŔťıçȉpǎǹţș',
];
$this
->drupalPostForm('search/node', $edit, t('Search'));
$this
->assertRaw('<strong>cómmīŦŧęđ</strong>');
$this
->assertRaw('<strong>BɆĬŇĜ</strong>');
$this
->assertRaw('<strong>påŔťıçȉpǎǹţș</strong>');
$edit = [
'keys' => 'committed being participants',
];
$this
->drupalPostForm('search/node', $edit, t('Search'));
$this
->assertRaw('<strong>cómmīŦŧęđ</strong>');
$this
->assertRaw('<strong>BɆĬŇĜ</strong>');
$this
->assertRaw('<strong>påŔťıçȉpǎǹţș</strong>');
$edit = [
'keys' => 'Enricþment',
];
$this
->drupalPostForm('search/node', $edit, t('Search'));
$this
->assertRaw('<strong>Enricþment</strong>');
$edit = [
'keys' => 'Enritchment',
];
$this
->drupalPostForm('search/node', $edit, t('Search'));
$this
->assertNoRaw('<strong>Enricþment</strong>');
$edit = [
'keys' => 'æll',
];
$this
->drupalPostForm('search/node', $edit, t('Search'));
$this
->assertRaw('<strong>æll</strong>');
$edit = [
'keys' => 'all',
];
$this
->drupalPostForm('search/node', $edit, t('Search'));
$this
->assertNoRaw('<strong>æll</strong>');
}
}