function SearchLanguageTest::testLanguageAttributes
Same name in other branches
- 10 core/modules/search/tests/src/Functional/SearchLanguageTest.php \Drupal\Tests\search\Functional\SearchLanguageTest::testLanguageAttributes()
- 11.x core/modules/search/tests/src/Functional/SearchLanguageTest.php \Drupal\Tests\search\Functional\SearchLanguageTest::testLanguageAttributes()
Test language attribute "lang" for the search results.
File
-
core/
modules/ search/ tests/ src/ Functional/ SearchLanguageTest.php, line 163
Class
- SearchLanguageTest
- Tests advanced search with different languages added.
Namespace
Drupal\Tests\search\FunctionalCode
public function testLanguageAttributes() {
$this->drupalGet('search/node');
$this->submitForm([
'keys' => 'the Spanish title',
], 'Search');
$node = $this->searchableNodes[1]
->getTranslation('es');
$this->assertSession()
->elementExists('xpath', '//div[@class="layout-content"]//ol/li/h3[contains(@lang, "es")]');
$this->assertSession()
->elementTextEquals('xpath', '//div[@class="layout-content"]//ol/li/h3[contains(@lang, "es")]/a', $node->getTitle());
$this->assertSession()
->elementExists('xpath', '//div[@class="layout-content"]//ol/li/p[contains(@lang, "es")]');
// Visit the search form in Spanish language.
$this->drupalGet('es/search/node');
$this->submitForm([
'keys' => 'First node',
], 'Search');
$this->assertSession()
->elementExists('xpath', '//div[@class="layout-content"]//ol/li/h3[contains(@lang, "en")]');
$node = $this->searchableNodes[0]
->getTranslation('en');
$this->assertSession()
->elementTextEquals('xpath', '//div[@class="layout-content"]//ol/li/h3[contains(@lang, "en")]/a', $node->getTitle());
$this->assertSession()
->elementExists('xpath', '//div[@class="layout-content"]//ol/li/p[contains(@lang, "en")]');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.