You are here

function SkinrInstallationTestCase::testInstallation in Skinr 7.2

Tests installation and uninstallation of Skinr modules.

File

tests/skinr.test, line 90
Tests for the Skinr module.

Class

SkinrInstallationTestCase
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[Skinr][skinr][enable]' => TRUE,
    'modules[Skinr][skinr_ui][enable]' => TRUE,
  );
  $this
    ->drupalPost('admin/modules', $edit, t('Save configuration'));

  // Grant permissions.
  $edit = array(
    DRUPAL_AUTHENTICATED_RID . '[administer skinr]' => 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 Skinr's administration pages.
  $this
    ->drupalGet('admin/structure/skinr');
  $this
    ->assertResponse(200);

  // Uninstall the modules.
  $edit = array(
    'modules[Skinr][skinr_ui][enable]' => FALSE,
  );
  $this
    ->drupalPost('admin/modules', $edit, t('Save configuration'));
  $edit = array(
    'modules[Skinr][skinr][enable]' => FALSE,
  );
  $this
    ->drupalPost(NULL, $edit, t('Save configuration'));

  // Uninstall Skinr UI first.
  $edit = array(
    'uninstall[skinr_ui]' => TRUE,
  );
  $this
    ->drupalPost('admin/modules/uninstall', $edit, t('Uninstall'));
  $this
    ->drupalPost(NULL, array(), t('Uninstall'));

  // Now uninstall Skinr.
  $edit = array(
    'uninstall[skinr]' => 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 'skinr_*'")
    ->fetchField();
  $this
    ->assertEqual($count, 0, t('No variables found.'));
}