function LanguageConfigurationTest::checkConfigurableLanguageWeight

Validates system languages are ordered after configurable languages.

Parameters

string $state: (optional) A string for customizing assert messages, containing the description of the state of the check, for example: 'after re-ordering'. Defaults to 'by default'.

1 call to LanguageConfigurationTest::checkConfigurableLanguageWeight()
LanguageConfigurationTest::testLanguageConfigurationWeight in core/modules/language/tests/src/Functional/LanguageConfigurationTest.php
Functional tests for setting system language weight on adding, editing and deleting languages.

File

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

Class

LanguageConfigurationTest
Adds and configures languages to check negotiation changes.

Namespace

Drupal\Tests\language\Functional

Code

protected function checkConfigurableLanguageWeight($state = 'by default') {
  // Reset language list.
  \Drupal::languageManager()->reset();
  $max_configurable_language_weight = $this->getHighestConfigurableLanguageWeight();
  $replacements = [
    '@event' => $state,
  ];
  foreach (\Drupal::languageManager()->getLanguages(LanguageInterface::STATE_LOCKED) as $locked_language) {
    $replacements['%language'] = $locked_language->getName();
    $this->assertTrue($locked_language->getWeight() > $max_configurable_language_weight, new FormattableMarkup('System language %language has higher weight than configurable languages @event', $replacements));
  }
}

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