function AliasManagerTest::testGetAliasByPathNoMatch
Tests the getAliasByPath method for a path that has no matching alias.
@legacy-covers ::getAliasByPath
File
-
core/
modules/ path_alias/ tests/ src/ Unit/ AliasManagerTest.php, line 185
Class
Namespace
Drupal\Tests\path_alias\UnitCode
public function testGetAliasByPathNoMatch() : void {
$path_part1 = $this->randomMachineName();
$path_part2 = $this->randomMachineName();
$path = '/' . $path_part1 . '/' . $path_part2;
$language = $this->setUpCurrentLanguage();
$this->aliasPrefixList
->expects($this->any())
->method('get')
->with($path_part1)
->willReturn(TRUE);
$this->aliasRepository
->expects($this->once())
->method('preloadPathAlias')
->with([
$path => $path,
], $language->getId())
->willReturn([]);
$this->assertEquals($path, $this->aliasManager
->getAliasByPath($path));
// Call it twice to test the static cache.
$this->assertEquals($path, $this->aliasManager
->getAliasByPath($path));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.