function UpdateScriptTest::runUpdates

Same name and namespace in other branches
  1. 8.9.x core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php \Drupal\Tests\system\Functional\UpdateSystem\UpdateScriptTest::runUpdates()
  2. 10 core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php \Drupal\Tests\system\Functional\UpdateSystem\UpdateScriptTest::runUpdates()
  3. 11.x core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php \Drupal\Tests\system\Functional\UpdateSystem\UpdateScriptTest::runUpdates()

Helper function to run updates via the browser.

2 calls to UpdateScriptTest::runUpdates()
UpdateScriptTest::testMaintenanceModeUpdateFunctionality in core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php
Tests update.php while in maintenance mode.
UpdateScriptTest::testSuccessfulUpdateFunctionality in core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php
Tests update.php after performing a successful update.

File

core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php, line 681

Class

UpdateScriptTest
Tests the update script access and functionality.

Namespace

Drupal\Tests\system\Functional\UpdateSystem

Code

protected function runUpdates($maintenance_mode) {
    
    /** @var \Drupal\Core\Update\UpdateHookRegistry $update_registry */
    $update_registry = \Drupal::service('update.update_hook_registry');
    $schema_version = $update_registry->getInstalledVersion('update_script_test');
    $this->assertEquals(8001, $schema_version, 'update_script_test is initially installed with schema version 8001.');
    // Set the installed schema version to one less than the current update.
    $update_registry->setInstalledVersion('update_script_test', $schema_version - 1);
    $schema_version = $update_registry->getInstalledVersion('update_script_test');
    $this->assertEquals(8000, $schema_version, 'update_script_test schema version overridden to 8000.');
    // Click through update.php with 'administer software updates' permission.
    $this->drupalLogin($this->updateUser);
    if ($maintenance_mode) {
        $this->assertSession()
            ->pageTextContains('Operating in maintenance mode.');
    }
    else {
        $this->assertSession()
            ->pageTextNotContains('Operating in maintenance mode.');
    }
    $this->drupalGet($this->updateUrl, [
        'external' => TRUE,
    ]);
    $this->updateRequirementsProblem();
    $this->clickLink('Continue');
    $this->clickLink('Apply pending updates');
    $this->checkForMetaRefresh();
    // Verify that updates were completed successfully.
    $this->assertSession()
        ->pageTextContains('Updates were attempted.');
    $this->assertSession()
        ->linkExists('site');
    $this->assertSession()
        ->pageTextContains('The update_script_test_update_8001() update was executed successfully.');
    // Verify that no 7.x updates were run.
    $this->assertSession()
        ->pageTextNotContains('The update_script_test_update_7200() update was executed successfully.');
    $this->assertSession()
        ->pageTextNotContains('The update_script_test_update_7201() update was executed successfully.');
    // Verify that there are no links to different parts of the workflow.
    $this->assertSession()
        ->linkNotExists('Administration pages');
    $this->assertSession()
        ->elementNotExists('xpath', '//main//a[contains(@href, "update.php")]');
    $this->assertSession()
        ->linkNotExists('logged');
    // Verify the front page can be visited following the upgrade.
    $this->clickLink('Front page');
    $this->assertSession()
        ->statusCodeEquals(200);
}

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