public function testTranslatedBreadcrumbs() { // Ensure non-translated breadcrumb is correct.
$breadcrumb =
[Url::
fromRoute('<front>'
)->
toString() => 'Home'
];
foreach ($this->terms
as $term) { $breadcrumb[$term->
toUrl()->
toString()] =
$term->
label();
} // The last item will not be in the breadcrumb.
array_pop($breadcrumb);
// Check the breadcrumb on the leaf term page.
$term =
$this->
getLeafTerm();
$this->
assertBreadcrumb($term->
toUrl(),
$breadcrumb,
$term->
label());
$languages = \Drupal::
languageManager()->
getLanguages();
// Construct the expected translated breadcrumb.
$breadcrumb =
[Url::
fromRoute('<front>',
[],
['language' =>
$languages[$this->translateToLangcode
]])->
toString() => 'Home'
];
foreach ($this->terms
as $term) { $translated =
$term->
getTranslation($this->translateToLangcode
);
$url =
$translated->
toUrl('canonical',
['language' =>
$languages[$this->translateToLangcode
]])->
toString();
$breadcrumb[$url] =
$translated->
label();
}