You are here

public function SearchNodeDiacriticsTest::testPhraseSearchPunctuation in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/search/tests/src/Functional/SearchNodeDiacriticsTest.php \Drupal\Tests\search\Functional\SearchNodeDiacriticsTest::testPhraseSearchPunctuation()

Tests that search returns results with diacritics in the search phrase.

File

core/modules/search/tests/src/Functional/SearchNodeDiacriticsTest.php, line 51

Class

SearchNodeDiacriticsTest
Tests search functionality with diacritics.

Namespace

Drupal\Tests\search\Functional

Code

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,
      ],
    ],
  ]);

  // Update the search index.
  $this->container
    ->get('plugin.manager.search')
    ->createInstance('node_search')
    ->updateIndex();

  // Refresh variables after the treatment.
  $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>');
}