You are here

public function LanguageNeutralAliasesTest::testLookupBySystemPath in Language neutral aliases 8.2

Same name and namespace in other branches
  1. 3.x tests/src/Kernel/LanguageNeutralAliasesTest.php \Drupal\Tests\language_neutral_aliases\Kernel\LanguageNeutralAliasesTest::testLookupBySystemPath()

Test that lookupBySystemPath() only returns language neutral aliases.

File

tests/src/Kernel/LanguageNeutralAliasesTest.php, line 152

Class

LanguageNeutralAliasesTest
Test language neutral aliases.

Namespace

Drupal\Tests\language_neutral_aliases\Kernel

Code

public function testLookupBySystemPath() {
  $repository = $this->container
    ->get('path_alias.repository');
  $this
    ->assertEqual([
    'id' => 3,
    'path' => '/node/3',
    'alias' => '/path/third',
    'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
  ], $repository
    ->lookupBySystemPath('/node/3', LanguageInterface::LANGCODE_NOT_SPECIFIED));
  $this
    ->assertEqual([
    'id' => 3,
    'path' => '/node/3',
    'alias' => '/path/third',
    'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
  ], $repository
    ->lookupBySystemPath('/node/3', 'de'));

  // Check that non-neutral aliases aren't returned.
  $this
    ->assertNull($repository
    ->lookupBySystemPath('/node/1', LanguageInterface::LANGCODE_NOT_SPECIFIED));
  $this
    ->assertNull($repository
    ->lookupBySystemPath('/node/1', 'de'));
}