You are here

function LanguageConfigurationTest::testLanguageConfigurationWeight in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/language/src/Tests/LanguageConfigurationTest.php \Drupal\language\Tests\LanguageConfigurationTest::testLanguageConfigurationWeight()

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

File

core/modules/language/src/Tests/LanguageConfigurationTest.php, line 156
Contains \Drupal\language\Tests\LanguageConfigurationTest.

Class

LanguageConfigurationTest
Adds and configures languages to check negotiation changes.

Namespace

Drupal\language\Tests

Code

function testLanguageConfigurationWeight() {

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

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

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

  // Remove predefined language.
  $edit = array(
    'confirm' => 1,
  );
  $this
    ->drupalPostForm('admin/config/regional/language/delete/fr', $edit, 'Delete');
  $this
    ->checkConfigurableLanguageWeight('after deleting a language');
}