You are here

function MailhandlerTestCase::testMailhandlerSettings in Mailhandler 6

Verify the functionality of the administrative interface when the user has no privileges to edit filter formats.

File

./mailhandler.test, line 236
Simpletest case for mailhandler module.

Class

MailhandlerTestCase
Functionality tests for mailhandler module.

Code

function testMailhandlerSettings() {

  // Create and login user.
  $account = $this
    ->drupalCreateUser(array(
    'administer mailhandler',
  ));
  $this
    ->drupalLogin($account);

  // Verify default settings
  $this
    ->drupalGet('admin/settings/mailhandler');
  $this
    ->assertfieldByName('mailhandler_default_type', 'story');
  $this
    ->assertfieldByName('mailhandler_max_retrieval', '0');
  $this
    ->assertfieldByName('mailhandler_default_encoding', 'UTF-8');
  $this
    ->assertfieldByName('mailhandler_watchdog_level', '6');

  // Change settings
  $settings = array(
    'mailhandler_default_type' => 'page',
    'mailhandler_max_retrieval' => '5',
    'mailhandler_default_encoding' => 'UTF-1',
    'mailhandler_watchdog_level' => '1',
  );
  $this
    ->drupalPost(NULL, $settings, t('Save configuration'));
  $this
    ->assertText(t('The configuration options have been saved.'));
  $this
    ->assertMailhandlerSettings($settings);

  // Cron maximun validation: empty
  $settings['mailhandler_max_retrieval'] = '';
  $this
    ->drupalPost(NULL, $settings, t('Save configuration'));
  $this
    ->assertText(t('The configuration options have been saved.'));
  $this
    ->assertMailhandlerSettings($settings);

  // Cron maximun validation: empty
  $settings['mailhandler_max_retrieval'] = '-1';
  $this
    ->drupalPost(NULL, $settings, t('Save configuration'));
  $this
    ->assertNoText(t('The configuration options have been saved.'));
  $this
    ->assertText(t('The value should a positive integer, or zero.'));
}