function LanguageUrlRewritingTest::setUp

Same name in other branches
  1. 9 core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php \Drupal\Tests\language\Functional\LanguageUrlRewritingTest::setUp()
  2. 8.9.x core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php \Drupal\Tests\language\Functional\LanguageUrlRewritingTest::setUp()
  3. 10 core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php \Drupal\Tests\language\Functional\LanguageUrlRewritingTest::setUp()

Overrides BrowserTestBase::setUp

File

core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php, line 41

Class

LanguageUrlRewritingTest
Tests that URL rewriting works as expected.

Namespace

Drupal\Tests\language\Functional

Code

protected function setUp() : void {
    parent::setUp();
    // Create and log in user.
    $this->webUser = $this->drupalCreateUser([
        'administer languages',
        'access administration pages',
    ]);
    $this->drupalLogin($this->webUser);
    // Install French language.
    $edit = [];
    $edit['predefined_langcode'] = 'fr';
    $this->drupalGet('admin/config/regional/language/add');
    $this->submitForm($edit, 'Add language');
    // Enable URL language detection and selection.
    $edit = [
        'language_interface[enabled][language-url]' => 1,
    ];
    $this->drupalGet('admin/config/regional/language/detection');
    $this->submitForm($edit, 'Save settings');
    // Check that drupalSettings contains path prefix.
    $this->drupalGet('fr/admin/config/regional/language/detection');
    $this->assertSession()
        ->responseContains('"pathPrefix":"fr\\/"');
}

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