function AliasManagerTest::testCacheClear
Same name in other branches
- 8.9.x core/modules/path_alias/tests/src/Unit/AliasManagerTest.php \Drupal\Tests\path_alias\Unit\AliasManagerTest::testCacheClear()
- 10 core/modules/path_alias/tests/src/Unit/AliasManagerTest.php \Drupal\Tests\path_alias\Unit\AliasManagerTest::testCacheClear()
- 11.x core/modules/path_alias/tests/src/Unit/AliasManagerTest.php \Drupal\Tests\path_alias\Unit\AliasManagerTest::testCacheClear()
@covers ::cacheClear
File
-
core/
modules/ path_alias/ tests/ src/ Unit/ AliasManagerTest.php, line 452
Class
- AliasManagerTest
- @coversDefaultClass \Drupal\path_alias\AliasManager @group path_alias
Namespace
Drupal\Tests\path_alias\UnitCode
public function testCacheClear() {
$path = '/path';
$alias = '/alias';
$language = $this->setUpCurrentLanguage();
$this->aliasRepository
->expects($this->exactly(2))
->method('lookupBySystemPath')
->with($path, $language->getId())
->willReturn([
'alias' => $alias,
]);
$this->aliasWhitelist
->expects($this->any())
->method('get')
->willReturn(TRUE);
// Populate the lookup map.
$this->assertEquals($alias, $this->aliasManager
->getAliasByPath($path, $language->getId()));
// Check that the cache is populated.
$this->aliasRepository
->expects($this->never())
->method('lookupByAlias');
$this->assertEquals($path, $this->aliasManager
->getPathByAlias($alias, $language->getId()));
// Clear specific source.
$this->aliasManager
->cacheClear($path);
// Ensure cache has been cleared (this will be the 2nd call to
// `lookupPathAlias` if cache is cleared).
$this->assertEquals($alias, $this->aliasManager
->getAliasByPath($path, $language->getId()));
// Clear non-existent source.
$this->aliasManager
->cacheClear('non-existent');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.