1 backup.test protected BackupBaseTestCase::restoreBackup()

Restore a backup via restore.php.

Return value

bool: TRUE if the restore succeeded, FALSE otherwise.

File

core/modules/simpletest/tests/backup.test, line 87
Test classes for verifying Backup and Restore functionality.

Class

BackupBaseTestCase
Base class for testing Backup and Restore functionality.

Code

protected function restoreBackup() {
  // Load the first update screen.
  $update_url = $GLOBALS['base_url'] . '/core/restore.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;
  }

  $this->backdropPost(NULL, array(), t('Restore backup'));

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

  if (!empty($this->restoreErrors)) {
    return FALSE;
  }

  $this->assertText(t('The backup was successfully restored.'));
  $this->assertLink(t('Return to your site'));

  return TRUE;
}