Perform the upgrade.
$register_errors: Register the errors during the upgrade process as failures.
TRUE if the upgrade succeeded, FALSE otherwise.
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;
}