You are here

protected function UpdateScriptTest::updateScriptTest in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Update/UpdateScriptTest.php \Drupal\system\Tests\Update\UpdateScriptTest::updateScriptTest()

Helper function to run updates via the browser.

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

File

core/modules/system/src/Tests/Update/UpdateScriptTest.php, line 224
Contains \Drupal\system\Tests\Update\UpdateScriptTest.

Class

UpdateScriptTest
Tests the update script access and functionality.

Namespace

Drupal\system\Tests\Update

Code

protected function updateScriptTest($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, array(
    'external' => TRUE,
  ));
  $this
    ->clickLink(t('Continue'));
  $this
    ->clickLink(t('Apply pending updates'));

  // Verify that updates were completed successfully.
  $this
    ->assertText('Updates were attempted.');
  $this
    ->assertLink('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
    ->assertNoLink('Administration pages');
  $this
    ->assertNoLinkByHrefInMainRegion('update.php', 0);
  $this
    ->assertNoLink('logged');

  // Verify the front page can be visited following the upgrade.
  $this
    ->clickLink('Front page');
  $this
    ->assertResponse(200);
}