You are here

public function AliasManagerTest::testGetPathByAliasNoMatch in Zircon Profile 8

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

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

@covers ::getPathByAlias

File

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

Class

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

Namespace

Drupal\Tests\Core\Path

Code

public function testGetPathByAliasNoMatch() {
  $alias = '/' . $this
    ->randomMachineName();
  $language = new Language(array(
    'id' => 'en',
  ));
  $this->languageManager
    ->expects($this
    ->any())
    ->method('getCurrentLanguage')
    ->with(LanguageInterface::TYPE_URL)
    ->will($this
    ->returnValue($language));
  $this->aliasStorage
    ->expects($this
    ->once())
    ->method('lookupPathSource')
    ->with($alias, $language
    ->getId())
    ->will($this
    ->returnValue(NULL));
  $this
    ->assertEquals($alias, $this->aliasManager
    ->getPathByAlias($alias));

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