function AliasManagerTest::testGetPathByAliasMatch

Same name and namespace in other branches
  1. 11.x core/modules/path_alias/tests/src/Unit/AliasManagerTest.php \Drupal\Tests\path_alias\Unit\AliasManagerTest::testGetPathByAliasMatch()
  2. 10 core/modules/path_alias/tests/src/Unit/AliasManagerTest.php \Drupal\Tests\path_alias\Unit\AliasManagerTest::testGetPathByAliasMatch()
  3. 9 core/modules/path_alias/tests/src/Unit/AliasManagerTest.php \Drupal\Tests\path_alias\Unit\AliasManagerTest::testGetPathByAliasMatch()
  4. 8.9.x core/modules/path_alias/tests/src/Unit/AliasManagerTest.php \Drupal\Tests\path_alias\Unit\AliasManagerTest::testGetPathByAliasMatch()

Tests the getPathByAlias method for an alias that have a matching path.

File

core/modules/path_alias/tests/src/Unit/AliasManagerTest.php, line 113

Class

AliasManagerTest
Tests Drupal\path_alias\AliasManager.

Namespace

Drupal\Tests\path_alias\Unit

Code

public function testGetPathByAliasMatch() : void {
  $alias = $this->randomMachineName();
  $path = $this->randomMachineName();
  $language = $this->setUpCurrentLanguage();
  $this->aliasRepository
    ->expects($this->once())
    ->method('lookupByAlias')
    ->with($alias, $language->getId())
    ->willReturn([
    'path' => $path,
    'alias' => $alias,
  ]);
  $this->assertEquals($path, $this->aliasManager
    ->getPathByAlias($alias));
  // Call it twice to test the static cache.
  $this->assertEquals($path, $this->aliasManager
    ->getPathByAlias($alias));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.