You are here

public function LanguageConfigurationTest::testLanguageConfigurationWeight in Drupal 10

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

Functional tests for setting system language weight on adding, editing and deleting languages.

File

core/modules/language/tests/src/Functional/LanguageConfigurationTest.php, line 163

Class

LanguageConfigurationTest
Adds and configures languages to check negotiation changes.

Namespace

Drupal\Tests\language\Functional

Code

public function testLanguageConfigurationWeight() {

  // User to add and remove language.
  $admin_user = $this
    ->drupalCreateUser([
    'administer languages',
    'access administration pages',
  ]);
  $this
    ->drupalLogin($admin_user);
  $this
    ->checkConfigurableLanguageWeight();

  // Add predefined language.
  $edit = [
    'predefined_langcode' => 'fr',
  ];
  $this
    ->drupalGet('admin/config/regional/language/add');
  $this
    ->submitForm($edit, 'Add language');
  $this
    ->checkConfigurableLanguageWeight('after adding new language');

  // Re-ordering languages.
  $edit = [
    'languages[en][weight]' => $this
      ->getHighestConfigurableLanguageWeight() + 1,
  ];
  $this
    ->drupalGet('admin/config/regional/language');
  $this
    ->submitForm($edit, 'Save configuration');
  $this
    ->checkConfigurableLanguageWeight('after re-ordering');

  // Remove predefined language.
  $this
    ->drupalGet('admin/config/regional/language/delete/fr');
  $this
    ->submitForm([], 'Delete');
  $this
    ->checkConfigurableLanguageWeight('after deleting a language');
}