You are here

protected function LanguageUrlRewritingTest::setUp in Drupal 8

Same name and namespace in other branches
  1. 9 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() {
  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
    ->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));

  // Enable URL language detection and selection.
  $edit = [
    'language_interface[enabled][language-url]' => 1,
  ];
  $this
    ->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));

  // Check that drupalSettings contains path prefix.
  $this
    ->drupalGet('fr/admin/config/regional/language/detection');
  $this
    ->assertRaw('"pathPrefix":"fr\\/"', 'drupalSettings path prefix contains language code.');
}