You are here

public function DeprecatedPathHooksTest::testUpdate in Drupal 8

@covers ::save

@expectedDeprecation The deprecated hook hook_path_update() is implemented in these functions: path_deprecated_test_path_update(). It will be removed before Drupal 9.0.0. Use hook_ENTITY_TYPE_update() for the 'path_alias' entity type instead. See https://www.drupal.org/node/3013865.

File

core/modules/system/tests/src/Kernel/DeprecatedPathHooksTest.php, line 48

Class

DeprecatedPathHooksTest
@coversDefaultClass \Drupal\Core\Path\AliasStorage

Namespace

Drupal\Tests\system\Kernel

Code

public function testUpdate() {
  $source = '/' . $this
    ->randomMachineName();
  $alias = '/' . $this
    ->randomMachineName();
  $alias_storage = \Drupal::service('path.alias_storage');
  $alias_storage
    ->save($source, $alias);
  $new_source = '/' . $this
    ->randomMachineName();
  $path = $alias_storage
    ->load([
    'source' => $source,
  ]);
  $alias_storage
    ->save($new_source, $alias, LanguageInterface::LANGCODE_NOT_SPECIFIED, $path['pid']);
}