function UpdatePathTestBaseTest::testPathAliasProcessing

Same name in other branches
  1. 9 core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBaseTest.php \Drupal\FunctionalTests\Update\UpdatePathTestBaseTest::testPathAliasProcessing()
  2. 8.9.x core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBaseTest.php \Drupal\FunctionalTests\Update\UpdatePathTestBaseTest::testPathAliasProcessing()
  3. 11.x core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBaseTest.php \Drupal\FunctionalTests\Update\UpdatePathTestBaseTest::testPathAliasProcessing()

Tests that path aliases are not processed during database updates.

File

core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBaseTest.php, line 79

Class

UpdatePathTestBaseTest
Tests the update path base class.

Namespace

Drupal\FunctionalTests\Update

Code

public function testPathAliasProcessing() : void {
    // Add a path alias for the '/admin' system path.
    $values = [
        'path' => '/admin/structure',
        'alias' => '/admin-structure-alias',
        'langcode' => 'und',
        'status' => 1,
    ];
    $database = \Drupal::database();
    $id = $database->insert('path_alias')
        ->fields($values + [
        'uuid' => \Drupal::service('uuid')->generate(),
    ])
        ->execute();
    $revision_id = $database->insert('path_alias_revision')
        ->fields($values + [
        'id' => $id,
        'revision_default' => 1,
    ])
        ->execute();
    $database->update('path_alias')
        ->fields([
        'revision_id' => $revision_id,
    ])
        ->condition('id', $id)
        ->execute();
    // Increment the schema version.
    \Drupal::state()->set('update_test_schema_version', 8002);
    $this->runUpdates();
    // Check that the alias defined earlier is not used during the update
    // process.
    $this->assertSession()
        ->linkByHrefExists('/admin/structure');
    $this->assertSession()
        ->linkByHrefNotExists('/admin-structure-alias');
    $account = $this->createUser([
        'administer site configuration',
        'access administration pages',
        'access site reports',
    ]);
    $this->drupalLogin($account);
    // Go to the status report page and check that the alias is used.
    $this->drupalGet('admin/reports/status');
    $this->assertSession()
        ->linkByHrefNotExists('/admin/structure');
    $this->assertSession()
        ->linkByHrefExists('/admin-structure-alias');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.