summaryrefslogtreecommitdiff
path: root/modules/profile/profile.test
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2008-10-10 07:49:49 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2008-10-10 07:49:49 +0000
commit6828096e7e647c539f0a1ee644aa2d361f9dbf80 (patch)
tree91d9fb7e4f9973b24ab4195b09226e55a98a8ba8 /modules/profile/profile.test
parent8375d77ae25dd19c5b0c3623ce97d4c541c8c518 (diff)
downloadbrdo-6828096e7e647c539f0a1ee644aa2d361f9dbf80.tar.gz
brdo-6828096e7e647c539f0a1ee644aa2d361f9dbf80.tar.bz2
#284887 by Dave Reid and dww: Disable autocomplete if user does not have access to the callback.
Diffstat (limited to 'modules/profile/profile.test')
-rw-r--r--modules/profile/profile.test62
1 files changed, 60 insertions, 2 deletions
diff --git a/modules/profile/profile.test b/modules/profile/profile.test
index 8665457f7..485b79336 100644
--- a/modules/profile/profile.test
+++ b/modules/profile/profile.test
@@ -248,13 +248,71 @@ class ProfileTestWeights extends ProfileTestCase {
}
}
+/**
+ * Test profile field autocompletion and access.
+ */
+class ProfileTestAutocomplete extends ProfileTestCase {
+
+ /**
+ * Implementation of getInfo().
+ */
+ function getInfo() {
+ return array(
+ 'name' => t('Autocompletion'),
+ 'description' => t('Test profile fields with autocompletion.'),
+ 'group' => t('Profile')
+ );
+ }
+
+ /**
+ * Tests profile field autocompletion and access.
+ */
+ function testAutocomplete() {
+ $this->drupalLogin($this->admin_user);
+
+ // Create a new profile field with autocompletion enabled.
+ $category = $this->randomName();
+ $field = $this->createProfileField('textfield', $category, array('weight' => 1, 'autocomplete' => 1));
+
+ // Enter profile field value.
+ $field['value'] = $this->randomName();
+ $this->setProfileField($field, $field['value']);
+
+ // Set some html for what we want to see in the page output later.
+ $autocomplete_html = '<input class="autocomplete" type="hidden" id="' . form_clean_id('edit-' . $field['form_name'] . '-autocomplete') . '" value="' . url('profile/autocomplete/' . $field['fid'], array('absolute' => TRUE)) . '" disabled="disabled" />';
+ $field_html = '<input type="text" maxlength="255" name="' . $field['form_name'] . '" id="'. form_clean_id('edit-' . $field['form_name']) . '" size="60" value="' . $field['value'] . '" class="form-text form-autocomplete required" />';
+
+ // Check that autocompletion html is found on the user's profile edit page.
+ $this->drupalGet('user/' . $this->admin_user->uid . '/edit/' . $category);
+ $this->assertRaw($autocomplete_html, t('Autocomplete found.'));
+ $this->assertRaw('misc/autocomplete.js', t('Autocomplete JavaScript found.'));
+ $this->assertRaw('class="form-text form-autocomplete"', t('Autocomplete form element class found.'));
+
+ // Check the autocompletion path using the first letter of our user's profile
+ // field value to make sure access is allowed and a valid result if found.
+ $this->drupalGet('profile/autocomplete/' . $field['fid'] . '/' . $field['value'][0]);
+ $this->assertResponse(200, t('Autocomplete path allowed to user with permission.'));
+ $this->assertRaw($field['value'], t('Autocomplete value found.'));
+
+ // Logout and login with a user without the 'access user profiles' permission.
+ $this->drupalLogout();
+ $this->drupalLogin($this->normal_user);
+
+ // Check that autocompletion html is not found on the user's profile edit page.
+ $this->drupalGet('user/' . $this->normal_user->uid . '/edit/' . $category);
+ $this->assertNoRaw($autocomplete_html, t('Autocomplete not found.'));
+
+ // User should be denied access to the profile autocomplete path.
+ $this->drupalGet('profile/autocomplete/' . $field['fid'] . '/' . $field['value'][0]);
+ $this->assertResponse(403, t('Autocomplete path denied to user without permission.'));
+ }
+}
+
/**
* TODO:
* - Test field visibility
* - Test profile browsing
- * - Test autocomplete
* - Test required fields
* - Test fields on registration form
* - Test updating fields
*/
-