You are here

public function AliasManagerTest::testGetPathByAliasLangcode 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::testGetPathByAliasLangcode()

Tests the getPathByAlias method when a langcode is passed explicitly.

@covers ::getPathByAlias

File

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

Class

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

Namespace

Drupal\Tests\Core\Path

Code

public function testGetPathByAliasLangcode() {
  $alias = $this
    ->randomMachineName();
  $path = $this
    ->randomMachineName();
  $this->languageManager
    ->expects($this
    ->never())
    ->method('getCurrentLanguage');
  $this->aliasStorage
    ->expects($this
    ->once())
    ->method('lookupPathSource')
    ->with($alias, 'de')
    ->will($this
    ->returnValue($path));
  $this
    ->assertEquals($path, $this->aliasManager
    ->getPathByAlias($alias, 'de'));

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