You are here

function UpdateScriptFunctionalTest::testSuccessfulUpdateFunctionality in Drupal 7

Tests update.php after performing a successful update.

File

modules/system/system.test, line 2595
Tests for system.module.

Class

UpdateScriptFunctionalTest
Tests for the update system functionality.

Code

function testSuccessfulUpdateFunctionality() {
  drupal_set_installed_schema_version('update_script_test', drupal_get_installed_schema_version('update_script_test') - 1);

  // Click through update.php with 'administer software updates' permission.
  $this
    ->drupalLogin($this->update_user);
  $this
    ->drupalPost($this->update_url, array(), t('Continue'), array(
    'external' => TRUE,
  ));
  $this
    ->drupalPost(NULL, array(), t('Apply pending updates'));
  $this
    ->assertText('Updates were attempted.');
  $this
    ->assertLink('site');
  $this
    ->assertNoLink('Administration pages');
  $this
    ->assertNoLink('logged');
  $this
    ->clickLink('Front page');
  $this
    ->assertResponse(200);
  drupal_set_installed_schema_version('update_script_test', drupal_get_installed_schema_version('update_script_test') - 1);

  // Click through update.php with 'access administration pages' and
  // 'access site reports' permissions.
  $admin_user = $this
    ->drupalCreateUser(array(
    'administer software updates',
    'access administration pages',
    'access site reports',
  ));
  $this
    ->drupalLogin($admin_user);
  $this
    ->drupalPost($this->update_url, array(), t('Continue'), array(
    'external' => TRUE,
  ));
  $this
    ->drupalPost(NULL, array(), t('Apply pending updates'));
  $this
    ->assertText('Updates were attempted.');
  $this
    ->assertLink('logged');
  $this
    ->clickLink('Administration pages');
  $this
    ->assertResponse(200);
}