function ContactAttachContactFormsTestCase::checkExistenceOfAttachmentFields in Contact Attach 7
Checks existence of attachment fields on site-wide and user contact forms.
Parameters
int $rid: The role ID of the role to grant permissions.
object $user: (optional) A fully-loaded $user object of the user to log in. Defaults to NULL.
1 call to ContactAttachContactFormsTestCase::checkExistenceOfAttachmentFields()
- ContactAttachContactFormsTestCase::testContactAttachContactForms in ./
contact_attach.test - Tests the attachment functionality on the site-wide and user contact forms.
File
- ./
contact_attach.test, line 372 - Tests for the Contact Attach module.
Class
- ContactAttachContactFormsTestCase
- Tests the Contact Attach functionality for site-wide and user contact forms.
Code
function checkExistenceOfAttachmentFields($rid, $user = NULL) {
if ($user) {
$this
->drupalLoginWithUserGlobalRolesUpdate($user);
}
foreach ($this->contact_forms as $contact_form => $permission) {
$this
->drupalGet($contact_form);
// Ensure that there are no attachment fields when the user's roles do not
// have the necessary permissions to attach files.
$this
->assertNoRaw('files[contact_attach_1]', 'Attachment field does NOT appear on contact form.');
user_role_grant_permissions($rid, array(
$permission,
));
$this
->drupalGet($contact_form);
// Ensure that there is one attachment field when the user's roles have
// permission to attach files, but the settings for the roles have not
// been set.
$this
->assertRaw('files[contact_attach_1]', '1 attachment field appears on contact form.');
$this
->assertNoRaw('files[contact_attach_2]', 'More than 1 attachment field does NOT appear on contact form.');
}
if ($user) {
$this
->drupalLogoutWithUserGlobalRolesUpdate();
}
}