You are here

function MultipleEmailAdminUserTestCase::testMultipleEmailsAdminUser in Multiple E-mail Addresses 7

Same name and namespace in other branches
  1. 6 multiple_email.test \MultipleEmailAdminUserTestCase::testMultipleEmailsAdminUser()

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

File

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

Class

MultipleEmailAdminUserTestCase

Code

function testMultipleEmailsAdminUser() {

  // Test settings page is accessable
  $this
    ->drupalGet('admin/config/people/multiple-email');
  $this
    ->assertText(t('Multiple E-mails'));
  $this
    ->drupalPost('admin/config/people/multiple-email', array(), t('Save configuration'));
  $this
    ->assertText(t('The configuration options have been saved.'));

  // Test management of other users' multiple emails
  $this
    ->drupalGet('user/' . $this->basicuser->uid . '/edit/email-addresses');
  $email = multiple_email_find_address($this->basicuser->mail);

  // Check for access denied on the edit form
  $this
    ->drupalGet('user/' . $this->basicuser->uid . '/edit/email-addresses/edit/' . $email->eid);
  $this
    ->assertText(t('Access denied'), t('No access to edit form.'));

  // Submit the basicuser edit form
  $this
    ->drupalPost('user/' . $this->basicuser->uid . '/edit', array(), t('Save'));
  $this
    ->assertText(t('The changes have been saved.'));

  // Submit the basicuser edit form with a new e-mail address
  $new_email = $this
    ->randomName() . '@example.com';
  $edit = array(
    'mail' => $new_email,
  );
  $this
    ->drupalPost('user/' . $this->basicuser->uid . '/edit', $edit, t('Save'));
  $this
    ->assertRaw(t('The changes have been saved.'));
}