You are here

function ContactAttachSettingsFormTestCase::postValidRoleSettings in Contact Attach 7

Posts valid settings for the specified role on the module settings page.

Parameters

object $role: A fully-loaded role object as returned by user_role_load().

1 call to ContactAttachSettingsFormTestCase::postValidRoleSettings()
ContactAttachSettingsFormTestCase::runSettingsFormTestForRole in ./contact_attach.test
Tests the module settings form for the specified role.

File

./contact_attach.test, line 145
Tests for the Contact Attach module.

Class

ContactAttachSettingsFormTestCase
Tests the Contact Attach settings form.

Code

function postValidRoleSettings($role) {
  $max_size = format_size(file_upload_max_size());

  // Set valid settings.
  $field_values = array(
    'number_site[' . $role->rid . ']' => 3,
    'extensions_site[' . $role->rid . ']' => 'jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp patch',
    'uploadsize_site[' . $role->rid . ']' => $max_size - 0.1,
    'number_user[' . $role->rid . ']' => 2,
    'extensions_user[' . $role->rid . ']' => 'jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp xml',
    'uploadsize_user[' . $role->rid . ']' => $max_size - 0.2,
  );
  $edit = array();
  foreach ($field_values as $field_key => $field_value) {
    $edit['contact_attach_' . $field_key] = $field_value;
  }
  $this
    ->drupalPost('admin/config/media/contact_attach', $edit, t('Save configuration'));
  $this
    ->assertUniqueText(t('The configuration options have been saved.'), 'Settings successfully saved.');
  foreach ($field_values as $field_key => $field_value) {
    $this
      ->assertRaw('name="contact_attach_' . $field_key . '" value="' . $field_value . '"', 'Setting contact_attach_' . $field_key . ' was fetched properly after being saved.');
  }
}