function PrivatemsgEMailNotifyTestCase::testShowSenderMail in Privatemsg 7.2
Same name and namespace in other branches
- 6.2 pm_email_notify/pm_email_notify.test \PrivatemsgEMailNotifyTestCase::testShowSenderMail()
Test the "author's email address as notification sender" feature.
File
- pm_email_notify/
pm_email_notify.test, line 373 - Test file for pm_email_notify.module
Class
- PrivatemsgEMailNotifyTestCase
- @file Test file for pm_email_notify.module
Code
function testShowSenderMail() {
// Define a value for the "notification mails from" field.
$generic_sender = 'generic_sender@example.com';
// Test #1: Site wide setting is successfully stored (set to "show").
// Log in as admin and set the default to "show".
$this
->drupalLogin($this->admin);
$edit = array(
'privatemsg_setting_show_sender_mail' => TRUE,
// Also set the generic sender address while we're here.
'pm_email_notify_from' => $generic_sender,
);
$this
->drupalPost('admin/config/messaging/privatemsg', $edit, t('Save configuration'));
$this
->drupalGet('admin/config/messaging/privatemsg');
// Verify correct defaults.
$this
->assertFieldByName('privatemsg_setting_show_sender_mail', 1, "<em>Use sender's email address</em> value is now enabled in the form.");
// Test #2: User defaults match site-wide setting (currently "show").
// Log in as author and check for the custom field default.
$this
->drupalLogin($this->author);
$this
->drupalGet('user/' . $this->author->uid . '/edit');
$this
->assertFieldByName('pm_show_sender_mail', 1, "User's default setting for <em>show my email address</em> is also enabled.");
// Test #3: User can override the site-wide setting (back to "hide")
// and his private mail address will be hidden.
$edit = array(
'pm_show_sender_mail' => FALSE,
);
$this
->drupalPost(NULL, $edit, t('Save'));
$this
->drupalGet('user/' . $this->author->uid . '/edit');
$this
->assertFieldByName('pm_show_sender_mail', 0, "User successfully disabled his <em>show my email address</em> setting.");
// Let author send a test mail.
$message = array(
'recipient' => $this->recipient->name,
'subject' => $this
->randomName(),
'body[value]' => $this
->randomName(20),
);
$this
->drupalPost('messages/new', $message, t('Send message'));
$message['thread_id'] = $this
->getCurrentThreadId();
$recipients = array(
$this->recipient,
);
$this
->verifyMails($recipients, $this->author, $message, $generic_sender);
// Test #4: User can change his setting to "show" and his private
// mail address will be used.
$this
->drupalGet('user/' . $this->author->uid . '/edit');
$edit = array(
'pm_show_sender_mail' => TRUE,
);
$this
->drupalPost(NULL, $edit, t('Save'));
// Let author send a test mail.
$message = array(
'recipient' => $this->recipient->name,
'subject' => $this
->randomName(),
'body[value]' => $this
->randomName(20),
);
$this
->drupalPost('messages/new', $message, t('Send message'));
$message['thread_id'] = $this
->getCurrentThreadId();
$recipients = array(
$this->recipient,
);
$this
->verifyMails($recipients, $this->author, $message, $this->author->mail);
}