function MailhandlerTestCase::testMailhandlerDefaultFilterFormat in Mailhandler 6
Verify the functionality of the administrative interface when the user has no privileges to edit filter formats. Even if default format for all the mailboxes is FILTER_FORMAT_DEFAULT, it should not end up using this format, but any available format, preventing the filtering operation from working when this Drupal setting is changed.
File
- ./
mailhandler.test, line 189 - Simpletest case for mailhandler module.
Class
- MailhandlerTestCase
- Functionality tests for mailhandler module.
Code
function testMailhandlerDefaultFilterFormat() {
// Create and login user.
$account = $this
->drupalCreateUser(array(
'administer mailhandler',
));
$this
->drupalLogin($account);
// Create a mailbox using the Mailbox Add form. Put a value for every form
// field and try to avoid using defaults, to make sure they are all saved
// and populated again in the form. The email format will not be available
// as this user has not 'administer filters' privileges.
$mailbox = array(
'mail' => $this
->randomName() . '@simpletest.tld',
'mailto' => $this
->randomName() . '@simpletest.tld',
'folder' => variable_get('file_directory_temp', 'sites/default/files'),
'imap' => 1,
'domain' => $this
->randomName() . '.simpletest.tld',
'port' => rand(1, 1000),
'name' => $this
->randomName(),
'pass' => $this
->randomName(),
'extraimap' => $this
->randomName(),
'mime' => 'TEXT/PLAIN,TEXT/HTML',
'security' => 1,
'replies' => 0,
'fromheader' => $this
->randomName(),
'commands' => $this
->randomName(),
'sigseparator' => $this
->randomName(),
'delete_after_read' => 0,
'enabled' => 0,
'authentication' => 'mailhandler_default',
);
$this
->drupalPost('admin/content/mailhandler/add', $mailbox, t('Save mailbox'));
$this
->assertRaw(t('Mailbox %mailbox added.', array(
'%mailbox' => $mailbox['mail'],
)));
// Format for the mailbox must be set to any available for this user, so no
// no longer will hang the FILTER_FORMAT_DEFAULT value.
$format = db_result(db_query("SELECT mh.format FROM {mailhandler} mh WHERE mail = '%s'", $mailbox['mail']));
$this
->assertNotEqual($format, FILTER_FORMAT_DEFAULT, t('Default filter format is not use.'));
}