You are here

public function LanguageConfigurationTest::testLanguageConfigurationWeight in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/language/tests/src/Functional/LanguageConfigurationTest.php \Drupal\Tests\language\Functional\LanguageConfigurationTest::testLanguageConfigurationWeight()
  2. 10 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 161

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
    ->drupalPostForm('admin/config/regional/language/add', $edit, 'Add language');
  $this
    ->checkConfigurableLanguageWeight('after adding new language');

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

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