You are here

function FusionApplyInstallationTestCase::testInstallation in Fusion Accelerator 7.2

Same name and namespace in other branches
  1. 7 fusion_apply/tests/fusion_apply.test \FusionApplyInstallationTestCase::testInstallation()

Tests installation and uninstallation of Fusion Apply modules.

File

fusion_apply/tests/fusion_apply.test, line 29
Tests for the Fusion Apply module.

Class

FusionApplyInstallationTestCase
Tests basic module installation.

Code

function testInstallation() {
  $this->admin_user = $this
    ->drupalCreateUser(array(
    'access administration pages',
    'administer modules',
    'administer permissions',
  ));
  $this
    ->drupalLogin($this->admin_user);

  // Install the modules.
  $edit = array(
    'modules[Fusion][fusion_apply][enable]' => TRUE,
    'modules[Fusion][fusion_apply_ui][enable]' => TRUE,
    'modules[Fusion][fusion_apply_rules][enable]' => TRUE,
  );
  $this
    ->drupalPost('admin/modules', $edit, t('Save configuration'));

  // Grant permissions.
  $edit = array(
    DRUPAL_AUTHENTICATED_RID . '[administer fusion]' => TRUE,
    DRUPAL_AUTHENTICATED_RID . '[edit skin settings]' => TRUE,
    DRUPAL_AUTHENTICATED_RID . '[edit advanced skin settings]' => TRUE,
  );
  $this
    ->drupalPost('admin/people/permissions', $edit, t('Save permissions'));

  // Verify that we are able to access Fusion Apply's administration pages.
  $this
    ->drupalGet('admin/appearance/fusion');
  $this
    ->assertResponse(200);

  // Uninstall the modules.
  $edit = array(
    'modules[Fusion][fusion_apply_rules][enable]' => FALSE,
  );
  $this
    ->drupalPost('admin/modules', $edit, t('Save configuration'));
  $edit = array(
    'modules[Fusion][fusion_apply_ui][enable]' => FALSE,
  );
  $this
    ->drupalPost('admin/modules', $edit, t('Save configuration'));
  $edit = array(
    'modules[Fusion][fusion_apply][enable]' => FALSE,
  );
  $this
    ->drupalPost(NULL, $edit, t('Save configuration'));

  // First, uninstall Fusion Rules.
  $edit = array(
    'uninstall[fusion_apply_rules]' => TRUE,
  );
  $this
    ->drupalPost('admin/modules/uninstall', $edit, t('Uninstall'));
  $this
    ->drupalPost(NULL, array(), t('Uninstall'));

  // Next, uninstall Fusion Apply UI.
  $edit = array(
    'uninstall[fusion_apply_ui]' => TRUE,
  );
  $this
    ->drupalPost('admin/modules/uninstall', $edit, t('Uninstall'));
  $this
    ->drupalPost(NULL, array(), t('Uninstall'));

  // Finally, uninstall Fusion Apply.
  $edit = array(
    'uninstall[fusion_apply]' => TRUE,
  );
  $this
    ->drupalPost('admin/modules/uninstall', $edit, t('Uninstall'));
  $this
    ->drupalPost(NULL, array(), t('Uninstall'));

  // Verify that no system variables are left.
  $count = db_query("SELECT 1 FROM {variable} WHERE name LIKE 'fusion_apply_*'")
    ->fetchField();
  $this
    ->assertEqual($count, 0, t('No variables found.'));
}