protected function PathAliasTestTrait::createPathAlias in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Traits/Core/PathAliasTestTrait.php \Drupal\Tests\Traits\Core\PathAliasTestTrait::createPathAlias()
- 10 core/tests/Drupal/Tests/Traits/Core/PathAliasTestTrait.php \Drupal\Tests\Traits\Core\PathAliasTestTrait::createPathAlias()
Creates a new path alias.
Parameters
string $path: The system path.
string $alias: The alias for the system path.
string $langcode: (optional) A language code for the path alias. Defaults to \Drupal\Core\Language\LanguageInterface::LANGCODE_NOT_SPECIFIED.
Return value
\Drupal\path_alias\PathAliasInterface A path alias entity.
17 calls to PathAliasTestTrait::createPathAlias()
- AliasTest::testLookupByAlias in core/
modules/ path_alias/ tests/ src/ Kernel/ AliasTest.php - @covers ::lookupByAlias
- AliasTest::testLookupBySystemPath in core/
modules/ path_alias/ tests/ src/ Kernel/ AliasTest.php - @covers ::lookupBySystemPath
- AliasTest::testLookupPath in core/
modules/ path_alias/ tests/ src/ Kernel/ AliasTest.php - @covers \Drupal\path_alias\AliasManager::getPathByAlias @covers \Drupal\path_alias\AliasManager::getAliasByPath
- AliasTest::testWhitelist in core/
modules/ path_alias/ tests/ src/ Kernel/ AliasTest.php - Tests the alias whitelist.
- AliasTest::testWhitelistCacheDeletionMidRequest in core/
modules/ path_alias/ tests/ src/ Kernel/ AliasTest.php - Tests situation where the whitelist cache is deleted mid-request.
File
- core/
tests/ Drupal/ Tests/ Traits/ Core/ PathAliasTestTrait.php, line 28
Class
- PathAliasTestTrait
- Provides methods to create and assert path_alias entities.
Namespace
Drupal\Tests\Traits\CoreCode
protected function createPathAlias($path, $alias, $langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED) {
/** @var \Drupal\path_alias\PathAliasInterface $path_alias */
$path_alias = \Drupal::entityTypeManager()
->getStorage('path_alias')
->create([
'path' => $path,
'alias' => $alias,
'langcode' => $langcode,
]);
$path_alias
->save();
return $path_alias;
}