function AliasManagerTest::testGetAliasByPathWhitelist

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

Tests the getAliasByPath method for a path that is not in the whitelist.

@covers ::getAliasByPath

File

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

Class

AliasManagerTest
@coversDefaultClass <a href="/api/drupal/core%21modules%21path_alias%21src%21AliasManager.php/class/AliasManager/8.9.x" title="The default alias manager implementation." class="local">\Drupal\path_alias\AliasManager</a> @group path_alias

Namespace

Drupal\Tests\path_alias\Unit

Code

public function testGetAliasByPathWhitelist() {
    $path_part1 = $this->randomMachineName();
    $path_part2 = $this->randomMachineName();
    $path = '/' . $path_part1 . '/' . $path_part2;
    $this->setUpCurrentLanguage();
    $this->aliasWhitelist
        ->expects($this->any())
        ->method('get')
        ->with($path_part1)
        ->will($this->returnValue(FALSE));
    // The whitelist returns FALSE for that path part, so the storage should
    // never be called.
    $this->aliasRepository
        ->expects($this->never())
        ->method('lookupBySystemPath');
    $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.