You are here

protected function UpdateScriptTest::runUpdates in Drupal 8

Same name and namespace in other branches
  1. 9 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 687

Class

UpdateScriptTest
Tests the update script access and functionality.

Namespace

Drupal\Tests\system\Functional\UpdateSystem

Code

protected function runUpdates($maintenance_mode) {
  $schema_version = drupal_get_installed_schema_version('update_script_test');
  $this
    ->assertEqual($schema_version, 8001, 'update_script_test is initially installed with schema version 8001.');

  // Set the installed schema version to one less than the current update.
  drupal_set_installed_schema_version('update_script_test', $schema_version - 1);
  $schema_version = drupal_get_installed_schema_version('update_script_test', TRUE);
  $this
    ->assertEqual($schema_version, 8000, '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
      ->assertText('Operating in maintenance mode.');
  }
  else {
    $this
      ->assertNoText('Operating in maintenance mode.');
  }
  $this
    ->drupalGet($this->updateUrl, [
    'external' => TRUE,
  ]);
  $this
    ->updateRequirementsProblem();
  $this
    ->clickLink(t('Continue'));
  $this
    ->clickLink(t('Apply pending updates'));
  $this
    ->checkForMetaRefresh();

  // Verify that updates were completed successfully.
  $this
    ->assertText('Updates were attempted.');
  $this
    ->assertSession()
    ->linkExists('site');
  $this
    ->assertText('The update_script_test_update_8001() update was executed successfully.');

  // Verify that no 7.x updates were run.
  $this
    ->assertNoText('The update_script_test_update_7200() update was executed successfully.');
  $this
    ->assertNoText('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
    ->assertEmpty($this
    ->xpath('//main//a[contains(@href, :href)]', [
    ':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);
}