You are here

public function LanguageUILanguageNegotiationTest::testContentCustomization in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php \Drupal\Tests\language\Functional\LanguageUILanguageNegotiationTest::testContentCustomization()
  2. 9 core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php \Drupal\Tests\language\Functional\LanguageUILanguageNegotiationTest::testContentCustomization()

Tests persistence of negotiation settings for the content language type.

File

core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php, line 564

Class

LanguageUILanguageNegotiationTest
Tests the language UI for language switching.

Namespace

Drupal\Tests\language\Functional

Code

public function testContentCustomization() {

  // Customize content language settings from their defaults.
  $edit = [
    'language_content[configurable]' => TRUE,
    'language_content[enabled][language-url]' => FALSE,
    'language_content[enabled][language-session]' => TRUE,
  ];
  $this
    ->drupalGet('admin/config/regional/language/detection');
  $this
    ->submitForm($edit, 'Save settings');

  // Check if configurability persisted.
  $config = $this
    ->config('language.types');
  $this
    ->assertContains('language_interface', $config
    ->get('configurable'), 'Interface language is configurable.');
  $this
    ->assertContains('language_content', $config
    ->get('configurable'), 'Content language is configurable.');

  // Ensure configuration was saved.
  $this
    ->assertArrayNotHasKey('language-url', $config
    ->get('negotiation.language_content.enabled'));
  $this
    ->assertArrayHasKey('language-session', $config
    ->get('negotiation.language_content.enabled'));
}