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.

28 calls to UpgradePathTestBase::performUpgrade()
ActionUpgradePathTest::testActionUpgrade in drupal/core/modules/system/lib/Drupal/system/Tests/Upgrade/ActionUpgradePathTest.php
Tests to see if actions were upgrade.
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.
ContactUpgradePathTest::testContactUpgrade in drupal/core/modules/contact/lib/Drupal/contact/Tests/ContactUpgradePathTest.php
Tests upgrade of contact table to configuration entities.

... See full list

File

drupal/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php, line 230
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.');
  }

  // Ensure that the first update screen appeared correctly.
  if (!$this
    ->assertFieldByXPath('//input[@type="submit"]')) {
    throw new \Exception('An error was encountered during the first access to update.php.');
  }

  // Initialize config directories and rebuild the service container after
  // creating them in the first step.
  parent::prepareConfigDirectories();
  $this
    ->rebuildContainer();

  // 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.');
  }
  if (!$this
    ->assertNoText(t('An unrecoverable error has occurred.'))) {

    // Error occured during update process.
    throw new \Exception('POST to update.php to apply pending updates detected an unrecoverable error.');
  }

  // 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.');
  }

  // Allow tests to check the completion page.
  $this
    ->checkCompletionPage();

  // 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;

  // Force a variable refresh as we only just enabled it.
  $this
    ->refreshVariables();

  // Reload module list for modules that are enabled in the test database
  // but not on the test client.
  \Drupal::moduleHandler()
    ->resetImplementations();
  \Drupal::moduleHandler()
    ->reload();

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