function ContactAttachContactFormsTestCase::checkNumberOfAttachmentFields in Contact Attach 7
Checks the number of attachment fields after setting the variable.
Parameters
int $rid: The role ID of the role to be checked.
string $contact_attach_number: The number of attachments to be allowed for the role defined in $rid.
object $user: (optional) A fully-loaded $user object of the user to log in. Defaults to NULL.
1 call to ContactAttachContactFormsTestCase::checkNumberOfAttachmentFields()
- ContactAttachContactFormsTestCase::testContactAttachContactForms in ./
contact_attach.test - Tests the attachment functionality on the site-wide and user contact forms.
File
- ./
contact_attach.test, line 471 - Tests for the Contact Attach module.
Class
- ContactAttachContactFormsTestCase
- Tests the Contact Attach functionality for site-wide and user contact forms.
Code
function checkNumberOfAttachmentFields($rid, $contact_attach_number, $user = NULL) {
if ($user) {
$this
->drupalLoginWithUserGlobalRolesUpdate($user);
}
foreach ($this->contact_forms_short as $contact_form_short => $contact_form_path) {
if ($contact_form_short === 'site') {
$contact_form_permission = 'attach files on site-wide contact form';
}
elseif ($contact_form_short === 'user') {
$contact_form_permission = 'attach files on personal contact forms';
}
$this->attachment_numbers[$rid] = $contact_attach_number;
variable_set('contact_attach_number_' . $contact_form_short, $this->attachment_numbers);
$roles = _contact_attach_get_valid_roles($contact_form_permission, $this->attachment_numbers);
$attachments_allowed = _contact_attach_return_max_attachments($roles, $this->attachment_numbers);
$this
->drupalGet($contact_form_path);
$this
->assertRaw('files[contact_attach_' . $attachments_allowed . ']', $attachments_allowed . ' attachment fields appear on contact form.');
$this
->assertNoRaw('files[contact_attach_' . ($attachments_allowed + 1) . ']', 'More than ' . $attachments_allowed . ' attachment fields do NOT appear on contact form.');
}
if ($user) {
$this
->drupalLogoutWithUserGlobalRolesUpdate();
}
}