/**
* @covers \Drupal\path_alias\AliasManager::getPathByAlias
* @covers \Drupal\path_alias\AliasManager::getAliasByPath
*/
public function testLookupPath() { // Create AliasManager and Path object.
$aliasManager =
$this->container->
get('path_alias.manager'
);
// Test the situation where the source is the same for multiple aliases.
// Start with a language-neutral alias, which we will override.
$path_alias =
$this->
createPathAlias('/user/1', '/foo'
);
$this->
assertEquals($path_alias->
getAlias(),
$aliasManager->
getAliasByPath($path_alias->
getPath()), 'Basic alias lookup works.'
);
$this->
assertEquals($path_alias->
getPath(),
$aliasManager->
getPathByAlias($path_alias->
getAlias()), 'Basic source lookup works.'
);
// Create a language specific alias for the default language (English).
$path_alias =
$this->
createPathAlias('/user/1', '/users/Dries', 'en'
);
$this->
assertEquals($path_alias->
getAlias(),
$aliasManager->
getAliasByPath($path_alias->
getPath()), 'English alias overrides language-neutral alias.'
);
$this->
assertEquals($path_alias->
getPath(),
$aliasManager->
getPathByAlias($path_alias->
getAlias()), 'English source overrides language-neutral source.'
);
// Create a language-neutral alias for the same path, again.
$path_alias =
$this->
createPathAlias('/user/1', '/bar'
);
$this->
assertEquals("/users/Dries",
$aliasManager->
getAliasByPath($path_alias->
getPath()), 'English alias still returned after entering a language-neutral alias.'
);