/**
* Tests language fallback candidates.
*/
public function testCandidates() { $language_list =
$this->languageManager->
getLanguages();
$expected =
array_keys($language_list +
[LanguageInterface::LANGCODE_NOT_SPECIFIED => NULL
]);
// Check that language fallback candidates by default are all the available
// languages sorted by weight.
$candidates =
$this->languageManager->
getFallbackCandidates();
$this->
assertEquals($expected,
array_values($candidates), 'Language fallback candidates are properly returned.'
);
// Check that candidates are alterable.
$this->state->
set('language_test.fallback_alter.candidates', TRUE
);
$expected =
array_slice($expected, 0,
count($expected) - 1
);
$candidates =
$this->languageManager->
getFallbackCandidates();
$this->
assertEquals($expected,
array_values($candidates), 'Language fallback candidates are alterable.'
);
// Check that candidates are alterable for specific operations.
$this->state->
set('language_test.fallback_alter.candidates', FALSE
);
$this->state->
set('language_test.fallback_operation_alter.candidates', TRUE
);