public function AliasManagerTest::testGetAliasByPathNoMatch in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Core/Path/AliasManagerTest.php \Drupal\Tests\Core\Path\AliasManagerTest::testGetAliasByPathNoMatch()
Tests the getAliasByPath method for a path that has no matching alias.
@covers ::getAliasByPath
File
- core/
tests/ Drupal/ Tests/ Core/ Path/ AliasManagerTest.php, line 184 - Contains \Drupal\Tests\Core\Path\AliasManagerTest.
Class
- AliasManagerTest
- @coversDefaultClass \Drupal\Core\Path\AliasManager @group Path
Namespace
Drupal\Tests\Core\PathCode
public function testGetAliasByPathNoMatch() {
$path_part1 = $this
->randomMachineName();
$path_part2 = $this
->randomMachineName();
$path = '/' . $path_part1 . '/' . $path_part2;
$language = $this
->setUpCurrentLanguage();
$this->aliasManager
->setCacheKey($this->path);
$this->aliasWhitelist
->expects($this
->any())
->method('get')
->with($path_part1)
->will($this
->returnValue(TRUE));
$this->aliasStorage
->expects($this
->once())
->method('lookupPathAlias')
->with($path, $language
->getId())
->will($this
->returnValue(NULL));
$this
->assertEquals($path, $this->aliasManager
->getAliasByPath($path));
// Call it twice to test the static cache.
$this
->assertEquals($path, $this->aliasManager
->getAliasByPath($path));
// This needs to write out the cache.
$this->cache
->expects($this
->once())
->method('set')
->with($this->cacheKey, array(
$language
->getId() => array(
$path,
),
), (int) $_SERVER['REQUEST_TIME'] + 60 * 60 * 24);
$this->aliasManager
->writeCache();
}