function AliasManagerTest::testGetPathByAliasLangcode

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

Tests the getPathByAlias method when a langcode is passed explicitly.

@covers ::getPathByAlias

File

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

Class

AliasManagerTest
@coversDefaultClass \Drupal\path_alias\AliasManager @group path_alias

Namespace

Drupal\Tests\path_alias\Unit

Code

public function testGetPathByAliasLangcode() {
    $alias = $this->randomMachineName();
    $path = $this->randomMachineName();
    $this->languageManager
        ->expects($this->never())
        ->method('getCurrentLanguage');
    $this->aliasRepository
        ->expects($this->once())
        ->method('lookupByAlias')
        ->with($alias, 'de')
        ->willReturn([
        'path' => $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'));
}

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