You are here

function MultipleEmailLateInstallTestCase::testMultipleEmailsLateInstallModule in Multiple E-mail Addresses 6

Same name and namespace in other branches
  1. 7 multiple_email.test \MultipleEmailLateInstallTestCase::testMultipleEmailsLateInstallModule()

Test that the Multiple E-mails user can add a new e-mail address.

File

./multiple_email.test, line 276
Tests for the Multiple E-mail module

Class

MultipleEmailLateInstallTestCase

Code

function testMultipleEmailsLateInstallModule() {

  // Enable the Multiple E-mail module
  $this
    ->drupalGet('admin/build/modules');
  $this
    ->assertText('Multiple E-mail Addresses', t('Multiple E-mail Addresses module found'));
  $this
    ->drupalPost('admin/build/modules', array(
    'status[multiple_email]' => 'TRUE',
  ), t('Save configuration'));
  $this
    ->assertRaw(t("Multiple E-mail settings are available under !link", array(
    '!link' => l('Administer > Site configuration > Multiple E-mail Settings ', 'admin/settings/multiple-email'),
  )));
  $this
    ->assertRaw('<label class="option" for="edit-status-multiple-email"><input type="checkbox" name="status[multiple_email]" id="edit-status-multiple-email" value="multiple_email"  checked="checked"  class="form-checkbox" />', t('Multiple E-mail Addresses module checkbox checked'));

  // Enable Multiple E-mail Permissions
  $this
    ->drupalGet('admin/user/permissions');
  $this
    ->assertRaw('4[use multiple emails]');
  $this
    ->assertRaw(t('Save permissions'));
  $edit = array(
    '4[use multiple emails]' => TRUE,
  );
  $this
    ->drupalPost('admin/user/permissions', $edit, t('Save permissions'));

  // Verify that adminuser has access to settings page.
  $this
    ->drupalGet('admin/settings/multiple-email');
  $this
    ->assertText(t('Multiple E-mail Settings'));
  $this
    ->drupalPost('admin/settings/multiple-email', array(), t('Save configuration'));
  $this
    ->assertText(t('The configuration options have been saved.'));

  // Log in as emailuser.
  $this
    ->drupalLogin($this->emailuser);

  // emailuser should not have access to settings page.
  $this
    ->drupalGet('admin/settings/multiple-email');
  $this
    ->assertText(t('Access denied'));

  // Verify access to multiple e-mail addresses.
  $this
    ->drupalGet('user/' . $this->loggedInUser->uid . '/edit/email-addresses');
  $this
    ->assertText(t('Add new e-mail'));
  $address = multiple_email_find_address($this->loggedInUser->mail);
  $this
    ->assertText($this->loggedInUser->mail);

  // emailuser should not have access to edit addresses.
  $this
    ->assertNoRaw(l(t('Edit'), 'user/' . $this->loggedInUser->uid . '/edit/email-addresses/edit/' . $address->eid));

  // Log in as basicuser.
  $this
    ->drupalLogin($this->basicuser);

  // basicuser should not have access to settings page.
  $this
    ->drupalGet('admin/settings/multiple-email');
  $this
    ->assertText(t('Access denied'));

  // basicuser should not have access to E-mail Addresses page.
  $this
    ->drupalGet('user/' . $this->loggedInUser->uid . '/edit/email-addresses');
  $this
    ->assertText(t('Access denied'));

  // basicuser should have normal e-mail address field on user edit page.
  $this
    ->drupalGet('user/' . $this->loggedInUser->uid . '/edit');
  $this
    ->assertRaw('<input type="text" maxlength="64" name="mail" id="edit-mail" size="60" value="' . $this->loggedInUser->mail . '" class="form-text required" />');
}