You are here

public function AliasManagerTest::testGetPathByAliasNatch in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Path/AliasManagerTest.php \Drupal\Tests\Core\Path\AliasManagerTest::testGetPathByAliasNatch()

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

@covers ::getPathByAlias

File

core/tests/Drupal/Tests/Core/Path/AliasManagerTest.php, line 115
Contains \Drupal\Tests\Core\Path\AliasManagerTest.

Class

AliasManagerTest
@coversDefaultClass \Drupal\Core\Path\AliasManager @group Path

Namespace

Drupal\Tests\Core\Path

Code

public function testGetPathByAliasNatch() {
  $alias = $this
    ->randomMachineName();
  $path = $this
    ->randomMachineName();
  $language = $this
    ->setUpCurrentLanguage();
  $this->aliasStorage
    ->expects($this
    ->once())
    ->method('lookupPathSource')
    ->with($alias, $language
    ->getId())
    ->will($this
    ->returnValue($path));
  $this
    ->assertEquals($path, $this->aliasManager
    ->getPathByAlias($alias));

  // Call it twice to test the static cache.
  $this
    ->assertEquals($path, $this->aliasManager
    ->getPathByAlias($alias));
}