You are here

function ContactAttachSettingsFormTestCase::postInvalidRoleSettings in Contact Attach 7

Posts invalid 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::postInvalidRoleSettings()
ContactAttachSettingsFormTestCase::runSettingsFormTestForRole in ./contact_attach.test
Tests the module settings form for the specified role.

File

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

Class

ContactAttachSettingsFormTestCase
Tests the Contact Attach settings form.

Code

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

  // Set invalid settings.
  $edit = array(
    'contact_attach_number_site[' . $role->rid . ']' => 'n',
    'contact_attach_uploadsize_site[' . $role->rid . ']' => 'n',
    'contact_attach_number_user[' . $role->rid . ']' => 0,
    'contact_attach_uploadsize_user[' . $role->rid . ']' => 0,
  );
  $this
    ->drupalPost('admin/config/media/contact_attach', $edit, t('Save configuration'));
  $this
    ->assertNoText(t('The configuration options have been saved.'), 'Settings NOT successfully saved.');
  $this
    ->assertUniqueText(t('The number of file attachments for the @role role must be a positive integer.', array(
    '@role' => $role->name,
  )), 'Setting rightfully failed validation.');
  $this
    ->assertNoUniqueText(t('The @role role file size limit must be a number and greater than zero.', array(
    '@role' => $role->name,
  )), 'Setting rightfully failed validation.');
  $this
    ->assertUniqueText(t('The number of file attachments for the @role role cannot be 0. If you want to disable the ability of attaching files on contact forms for a role, revoke its permission on the permissions page.', array(
    '@role' => $role->name,
  )), 'Setting rightfully failed validation.');
  $edit = array(
    'contact_attach_uploadsize_site[' . $role->rid . ']' => $max_size + 1,
  );
  $this
    ->drupalPost('admin/config/media/contact_attach', $edit, t('Save configuration'));
  $this
    ->assertNoText(t('The configuration options have been saved.'), 'Settings NOT successfully saved.');
  $this
    ->assertRaw(t("Your PHP settings limit the maximum file size per upload to %size.<br/>Depending on your server environment, these settings may be changed in the system-wide php.ini file, a php.ini file in your Drupal root directory, in your Drupal site's settings.php file, or in the .htaccess file in your Drupal root directory.", array(
    '%size' => $max_size,
  )), 'Setting rightfully failed validation.');
}