function SearchNodeDiacriticsTest::testPhraseSearchPunctuation

Same name in other branches
  1. 9 core/modules/search/tests/src/Functional/SearchNodeDiacriticsTest.php \Drupal\Tests\search\Functional\SearchNodeDiacriticsTest::testPhraseSearchPunctuation()
  2. 8.9.x core/modules/search/tests/src/Functional/SearchNodeDiacriticsTest.php \Drupal\Tests\search\Functional\SearchNodeDiacriticsTest::testPhraseSearchPunctuation()
  3. 10 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 56

Class

SearchNodeDiacriticsTest
Tests search functionality with diacritics.

Namespace

Drupal\Tests\search\Functional

Code

public function testPhraseSearchPunctuation() : void {
    // cSpell:disable
    $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->drupalGet('search/node');
    $this->submitForm($edit, 'Search');
    $this->assertSession()
        ->responseContains('<strong>meklēt</strong>');
    $edit = [
        'keys' => 'meklēt',
    ];
    $this->drupalGet('search/node');
    $this->submitForm($edit, 'Search');
    $this->assertSession()
        ->responseContains('<strong>meklēt</strong>');
    $edit = [
        'keys' => 'cómmīŦŧęđ BɆĬŇĜ påŔťıçȉpǎǹţș',
    ];
    $this->drupalGet('search/node');
    $this->submitForm($edit, 'Search');
    $this->assertSession()
        ->responseContains('<strong>cómmīŦŧęđ</strong>');
    $this->assertSession()
        ->responseContains('<strong>BɆĬŇĜ</strong>');
    $this->assertSession()
        ->responseContains('<strong>påŔťıçȉpǎǹţș</strong>');
    $edit = [
        'keys' => 'committed being participants',
    ];
    $this->drupalGet('search/node');
    $this->submitForm($edit, 'Search');
    $this->assertSession()
        ->responseContains('<strong>cómmīŦŧęđ</strong>');
    $this->assertSession()
        ->responseContains('<strong>BɆĬŇĜ</strong>');
    $this->assertSession()
        ->responseContains('<strong>påŔťıçȉpǎǹţș</strong>');
    $edit = [
        'keys' => 'Enricþment',
    ];
    $this->drupalGet('search/node');
    $this->submitForm($edit, 'Search');
    $this->assertSession()
        ->responseContains('<strong>Enricþment</strong>');
    $edit = [
        'keys' => 'Enritchment',
    ];
    $this->drupalGet('search/node');
    $this->submitForm($edit, 'Search');
    $this->assertSession()
        ->responseNotContains('<strong>Enricþment</strong>');
    $edit = [
        'keys' => 'æll',
    ];
    $this->drupalGet('search/node');
    $this->submitForm($edit, 'Search');
    $this->assertSession()
        ->responseContains('<strong>æll</strong>');
    $edit = [
        'keys' => 'all',
    ];
    $this->drupalGet('search/node');
    $this->submitForm($edit, 'Search');
    $this->assertSession()
        ->responseNotContains('<strong>æll</strong>');
    // cSpell:enable
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.