LanguageNegotiationContentEntity::METHOD_ID => 0,
LanguageNegotiationUrl::METHOD_ID => 1,
]);
$config->
save();
// Without being on a content entity route the default entity URL tests
// should still pass.
$this->
testEntityUrlLanguage();
// Now switching to an entity route, so that the URL links are generated
// while being on an entity route.
$this->
setCurrentRequestForRoute('/entity_test/{entity_test}', 'entity.entity_test.canonical'
);
// The method language-content-entity should run before language-url and
// append query parameter for the content language and prevent language-url
// from overwriting the URL.
$this->
assertStringContainsString('/en/entity_test/' .
$this->entity->
id() . '?' . LanguageNegotiationContentEntity::QUERY_PARAMETER . '=en',
$this->entity->
toUrl('canonical'
)->
toString());
$this->
assertStringContainsString('/en/entity_test/' .
$this->entity->
id() . '?' . LanguageNegotiationContentEntity::QUERY_PARAMETER . '=es',
$this->entity->
getTranslation('es'
)->
toUrl('canonical'
)->
toString());
$this->
assertStringContainsString('/en/entity_test/' .
$this->entity->
id() . '?' . LanguageNegotiationContentEntity::QUERY_PARAMETER . '=fr',
$this->entity->
getTranslation('fr'
)->
toUrl('canonical'
)->
toString());
// Define the method language-url with a higher priority than
// language-content-entity. This configuration should match the default one,
// where the language-content-entity is turned off.