function LanguageConfigurationTest::testLanguageConfigurationWeight

Same name in other branches
  1. 9 core/modules/language/tests/src/Functional/LanguageConfigurationTest.php \Drupal\Tests\language\Functional\LanguageConfigurationTest::testLanguageConfigurationWeight()
  2. 8.9.x core/modules/language/tests/src/Functional/LanguageConfigurationTest.php \Drupal\Tests\language\Functional\LanguageConfigurationTest::testLanguageConfigurationWeight()
  3. 11.x 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() : void {
    // 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');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.