You are here

protected function LanguageUrlRewritingTest::setUp in Drupal 9

Same name and namespace in other branches
  1. 8 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 38

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\\/"');
}