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

AliasManagerTest
Tests Drupal\path_alias\AliasManager.

Namespace

Drupal\Tests\path_alias\Unit

Code

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.