protected function UpgradePathTestBase::performUpgrade

Perform the upgrade.

Parameters

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

Return value

TRUE if the upgrade succeeded, FALSE otherwise.

16 calls to UpgradePathTestBase::performUpgrade()
BareMinimalUpgradePathTest::testBasicMinimalUpgrade in drupal/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareMinimalUpgradePathTest.php
Tests a successful major version release upgrade.
BareStandardUpgradePathTest::testBasicStandardUpgrade in drupal/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareStandardUpgradePathTest.php
Tests a successful major version release upgrade.
BlockUpgradePathTest::testBlockUpgradeTitleLength in drupal/core/modules/system/lib/Drupal/system/Tests/Upgrade/BlockUpgradePathTest.php
Tests block title length after successful upgrade.
FilledMinimalUpgradePathTest::testFilledMinimalUpgrade in drupal/core/modules/system/lib/Drupal/system/Tests/Upgrade/FilledMinimalUpgradePathTest.php
Tests a successful point release update.
FilledStandardUpgradePathTest::testFilledStandardUpgrade in drupal/core/modules/system/lib/Drupal/system/Tests/Upgrade/FilledStandardUpgradePathTest.php
Tests a successful point release update.

... See full list

File

drupal/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php, line 190
Definition of Drupal\system\Tests\Upgrade\UpgradePathTestBase.

Class

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

Namespace

Drupal\system\Tests\Upgrade

Code

protected function performUpgrade($register_errors = TRUE) {

  // Load the first update screen.
  $this
    ->getUpdatePhp();
  if (!$this
    ->assertResponse(200)) {
    throw new Exception('Initial GET to update.php did not return HTTP 200 status.');
  }

  // Continue.
  $this
    ->drupalPost(NULL, array(), t('Continue'));
  if (!$this
    ->assertResponse(200)) {
    throw new Exception('POST to continue update.php did not return HTTP 200 status.');
  }

  // The test should pass if there are no pending updates.
  $content = $this
    ->drupalGetContent();
  if (strpos($content, t('No pending updates.')) !== FALSE) {
    $this
      ->pass('No pending updates and therefore no upgrade process to test.');
    $this->pendingUpdates = FALSE;
    return TRUE;
  }

  // Go!
  $this
    ->drupalPost(NULL, array(), t('Apply pending updates'));
  if (!$this
    ->assertResponse(200)) {
    throw new Exception('POST to update.php to apply pending updates did not return HTTP 200 status.');
  }

  // 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.
    throw new Exception('Errors during update process.');
  }

  // Check if there still are pending updates.
  $this
    ->getUpdatePhp();
  $this
    ->drupalPost(NULL, array(), t('Continue'));
  if (!$this
    ->assertText(t('No pending updates.'), 'No pending updates at the end of the update process.')) {
    throw new Exception('update.php still shows pending updates after execution.');
  }

  // 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.
  system_list_reset();
  module_implements_reset();
  module_load_all(FALSE, TRUE);

  // Rebuild the container and all caches.
  $this
    ->rebuildContainer();
  $this
    ->resetAll();
  return TRUE;
}