You are here

public function GlossaryViewTest::testGlossaryLanguagePrefix in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/views/tests/src/FunctionalJavascript/GlossaryViewTest.php \Drupal\Tests\views\FunctionalJavascript\GlossaryViewTest::testGlossaryLanguagePrefix()
  2. 9 core/modules/views/tests/src/FunctionalJavascript/GlossaryViewTest.php \Drupal\Tests\views\FunctionalJavascript\GlossaryViewTest::testGlossaryLanguagePrefix()

Tests that the glossary also works on a language prefixed URL.

File

core/modules/views/tests/src/FunctionalJavascript/GlossaryViewTest.php, line 105

Class

GlossaryViewTest
Tests the basic AJAX functionality of the Glossary View.

Namespace

Drupal\Tests\views\FunctionalJavascript

Code

public function testGlossaryLanguagePrefix() {
  ConfigurableLanguage::createFromLangcode('nl')
    ->save();
  $config = $this
    ->config('language.negotiation');
  $config
    ->set('url.prefixes', [
    'en' => 'en',
    'nl' => 'nl',
  ])
    ->save();
  \Drupal::service('kernel')
    ->rebuildContainer();
  $url = Url::fromRoute('view.test_glossary.page_1');
  $this
    ->drupalGet($url);
  $session = $this
    ->getSession();
  $web_assert = $this
    ->assertSession();
  $page = $session
    ->getPage();
  $rows = $page
    ->findAll('css', '.view-test-glossary tr');

  // We expect 2 rows plus the header row.
  $this
    ->assertCount(3, $rows);

  // Click on the P link, this should show 4 rows plus the header row.
  $page
    ->clickLink('P');
  $web_assert
    ->assertWaitOnAjaxRequest();
  $rows = $page
    ->findAll('css', '.view-test-glossary tr');
  $this
    ->assertCount(5, $rows);
}