1 upgrade.test protected UpgradePathTestCase::performUpgrade($register_errors = TRUE)

Perform the upgrade.

Parameters

$register_errors: Register the errors during the upgrade process as failures.

Return value

TRUE if the upgrade succeeded, FALSE otherwise.:

File

core/modules/simpletest/tests/upgrade/upgrade.test, line 170

Class

UpgradePathTestCase
Perform end-to-end tests of the upgrade path.

Code

protected function performUpgrade($register_errors = TRUE) {

  // Load the first update screen.
  $update_url = $GLOBALS['base_url'] . '/core/update.php';
  $this->backdropGet($update_url, array('external' => TRUE));
  if (!$this->assertResponse(200)) {
    return FALSE;
  }

  // Continue.
  $this->backdropPost(NULL, array(), t('Continue'));
  if (!$this->assertResponse(200)) {
    return FALSE;
  }

  // Go!
  $this->backdropPost(NULL, array(), t('Apply pending updates'));
  if (!$this->assertText(t('Updates were attempted'))) {
    return FALSE;
  }

  // Check for errors during the update process.
  foreach ($this->xpath('//li[@class=:class]', array(':class' => 'failure')) as $element) {
    $message = strip_tags($element->asXML());
    $this->upgradeErrors[] = $message;
    if ($register_errors) {
      $this->fail($message);
    }
  }

  if (!empty($this->upgradeErrors)) {
    // Upgrade failed, the installation might be in an inconsistent state,
    // don't process.
    return FALSE;
  }

  // Check if there still are pending updates.
  $this->backdropGet($update_url, array('external' => TRUE));
  $this->backdropPost(NULL, array(), t('Continue'));
  if (!$this->assertText(t('No pending updates.'), 'No pending updates at the end of the update process.')) {
    return FALSE;
  }

  // Upgrade succeed, rebuild the environment so that we can call the API
  // of the child site directly from this request.
  $this->upgradedSite = TRUE;

  // Reload module list. For modules that are enabled in the test database,
  // but not on the test client, we need to load the code here.
  $new_modules = array_diff(module_list(TRUE), $this->loadedModules);
  foreach ($new_modules as $module) {
    backdrop_load('module', $module);
  }

  // Reload hook implementations
  module_implements_reset();

  // Rebuild caches.
  backdrop_static_reset();
  backdrop_flush_all_caches();

  // Reload global $conf array and permissions.
  $this->refreshVariables();
  $this->checkPermissions(array(), TRUE);

  // Check we can load the home page of the new site.
  $this->backdropGet('');
  return $this->assertText('Powered by Backdrop CMS', 'The home page of the upgraded site loads successfully.');
}