You are here

protected function LanguageCookieTestBase::setUp in Language Cookie 8

Overrides BrowserTestBase::setUp

2 calls to LanguageCookieTestBase::setUp()
LanguageCookieLanguageSelectionPageTest::setUp in tests/src/Functional/LanguageCookieLanguageSelectionPageTest.php
LanguageCookiePageCacheTest::setUp in tests/src/Functional/LanguageCookiePageCacheTest.php
2 methods override LanguageCookieTestBase::setUp()
LanguageCookieLanguageSelectionPageTest::setUp in tests/src/Functional/LanguageCookieLanguageSelectionPageTest.php
LanguageCookiePageCacheTest::setUp in tests/src/Functional/LanguageCookiePageCacheTest.php

File

tests/src/Functional/LanguageCookieTestBase.php, line 36

Class

LanguageCookieTestBase
Base Class for Language Cookie Tests.

Namespace

Drupal\Tests\language_cookie\Functional

Code

protected function setUp() : void {
  parent::setUp();
  $admin = $this
    ->drupalCreateUser([], NULL, TRUE);
  $this
    ->drupalLogin($admin);
  $this
    ->drupalCreateContentType([
    'type' => 'page',
  ]);
  $this
    ->config('system.site')
    ->set('page.front', '/node')
    ->save();

  // Create FR.
  ConfigurableLanguage::createFromLangcode('fr')
    ->save();

  // Set prefixes to en and fr.
  $this
    ->drupalGet('admin/config/regional/language/detection/url');
  $this
    ->submitForm([
    'prefix[en]' => 'en',
    'prefix[fr]' => 'fr',
  ], 'Save configuration');

  // Set up URL, our fixed test negotiation and language cookie methods.
  $this
    ->drupalGet('admin/config/regional/language/detection');
  $this
    ->submitForm([
    'language_interface[enabled][' . LanguageNegotiationCookie::METHOD_ID . ']' => 1,
    'language_interface[enabled][language-url]' => 1,
    'language_interface[enabled][' . LanguageCookieFixedNegotiation::METHOD_ID . ']' => 1,
  ], 'Save settings');

  // Turn on content translation for pages.
  $config = ContentLanguageSettings::loadByEntityTypeBundle('node', 'page');
  $config
    ->setDefaultLangcode('en')
    ->setLanguageAlterable(TRUE)
    ->save();
}