// Set new default language.
\Drupal::
service('language.default'
)->
set($default_language);
\Drupal::
service('string_translation'
)->
setDefaultLangcode($default_language->
getId());
$languages = \Drupal::
service('language_manager'
)->
getLanguages(LanguageInterface::STATE_ALL
);
$this->
assertEquals(['default', 'und', 'zxx'
],
array_keys($languages));
$configurableLanguage = ConfigurableLanguage::
create(['label' =>
$this->
randomMachineName(), 'id' => 'test', 'weight' => 1
]);
// Simulate a configuration sync by setting the flag otherwise the locked
// language weights would be updated whilst saving.
// @see \Drupal\language\Entity\ConfigurableLanguage::postSave()
$configurableLanguage->
setSyncing(TRUE
)->
save();
$languages = \Drupal::
service('language_manager'
)->
getLanguages(LanguageInterface::STATE_ALL
);
$this->
assertEquals(['default', 'test', 'und', 'zxx'
],
array_keys($languages));
}}