function AliasManagerTest::testGetAliasByPathCachedMissLanguage
Same name and namespace in other branches
- 11.x core/modules/path_alias/tests/src/Unit/AliasManagerTest.php \Drupal\Tests\path_alias\Unit\AliasManagerTest::testGetAliasByPathCachedMissLanguage()
- 10 core/modules/path_alias/tests/src/Unit/AliasManagerTest.php \Drupal\Tests\path_alias\Unit\AliasManagerTest::testGetAliasByPathCachedMissLanguage()
- 9 core/modules/path_alias/tests/src/Unit/AliasManagerTest.php \Drupal\Tests\path_alias\Unit\AliasManagerTest::testGetAliasByPathCachedMissLanguage()
- 8.9.x core/modules/path_alias/tests/src/Unit/AliasManagerTest.php \Drupal\Tests\path_alias\Unit\AliasManagerTest::testGetAliasByPathCachedMissLanguage()
Tests the getAliasByPath cache when a different language is requested.
File
-
core/
modules/ path_alias/ tests/ src/ Unit/ AliasManagerTest.php, line 234
Class
Namespace
Drupal\Tests\path_alias\UnitCode
public function testGetAliasByPathCachedMissLanguage() : void {
$path_part1 = $this->randomMachineName();
$path_part2 = $this->randomMachineName();
$path = '/' . $path_part1 . '/' . $path_part2;
$alias = $this->randomMachineName();
$language = $this->setUpCurrentLanguage();
// @todo Test no longer tests anything different useful. Call explicitly
// with two different language codes?
$this->aliasPrefixList
->expects($this->any())
->method('get')
->with($path_part1)
->willReturn(TRUE);
// The requested language is different than the cached, so this will
// need to load.
$this->aliasRepository
->expects($this->once())
->method('preloadPathAlias')
->with([
$path => $path,
], $language->getId())
->willReturn([
$path => $alias,
]);
$this->assertEquals($alias, $this->aliasManager
->getAliasByPath($path));
// Call it twice to test the static cache.
$this->assertEquals($alias, $this->aliasManager
->getAliasByPath($path));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.