You are here

function UpdateScriptTest::testSuccessfulUpdateFunctionality 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::testSuccessfulUpdateFunctionality()

Tests update.php after performing a successful update.

File

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

Class

UpdateScriptTest
Tests the update script access and functionality.

Namespace

Drupal\system\Tests\Update

Code

function testSuccessfulUpdateFunctionality() {
  $initial_maintenance_mode = $this->container
    ->get('state')
    ->get('system.maintenance_mode');
  $this
    ->assertFalse($initial_maintenance_mode, 'Site is not in maintenance mode.');
  $this
    ->updateScriptTest($initial_maintenance_mode);
  $final_maintenance_mode = $this->container
    ->get('state')
    ->get('system.maintenance_mode');
  $this
    ->assertEqual($final_maintenance_mode, $initial_maintenance_mode, 'Maintenance mode should not have changed after database updates.');

  // Reset the static cache to ensure we have the most current setting.
  $schema_version = drupal_get_installed_schema_version('update_script_test', TRUE);
  $this
    ->assertEqual($schema_version, 8001, 'update_script_test schema version is 8001 after updating.');

  // 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 'access administration pages' and
  // 'access site reports' permissions.
  $admin_user = $this
    ->drupalCreateUser(array(
    'administer software updates',
    'access administration pages',
    'access site reports',
    'access site in maintenance mode',
  ));
  $this
    ->drupalLogin($admin_user);
  $this
    ->drupalGet($this->updateUrl, array(
    'external' => TRUE,
  ));
  $this
    ->clickLink(t('Continue'));
  $this
    ->clickLink(t('Apply pending updates'));
  $this
    ->assertText('Updates were attempted.');
  $this
    ->assertLink('logged');
  $this
    ->assertLink('Administration pages');
  $this
    ->assertNoLinkByHrefInMainRegion('update.php', 1);
  $this
    ->clickLink('Administration pages');
  $this
    ->assertResponse(200);
}