summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwebchick <webchick@24967.no-reply.drupal.org>2012-04-28 23:20:21 -0700
committerwebchick <webchick@24967.no-reply.drupal.org>2012-04-28 23:20:21 -0700
commit9afbc13d6bb62ee93e4ceabc6d9e22b61dcd7e91 (patch)
tree781fed4c8c5d10f7423e8c31aae41a5e979a45f9
parenta7d43f3460a97ad3c9b1cb23f7d374a4994837a3 (diff)
downloadbrdo-9afbc13d6bb62ee93e4ceabc6d9e22b61dcd7e91.tar.gz
brdo-9afbc13d6bb62ee93e4ceabc6d9e22b61dcd7e91.tar.bz2
Issue #1527988 by Niklas Fiekas: Fixed Missing or legacy number validation.
-rw-r--r--modules/filter/filter.module1
-rw-r--r--modules/filter/filter.test12
-rw-r--r--modules/search/search.admin.inc3
-rw-r--r--modules/search/search.test11
-rw-r--r--modules/user/user.admin.inc1
-rw-r--r--modules/user/user.test18
6 files changed, 45 insertions, 1 deletions
diff --git a/modules/filter/filter.module b/modules/filter/filter.module
index d7f86c8d7..6859ca894 100644
--- a/modules/filter/filter.module
+++ b/modules/filter/filter.module
@@ -1358,6 +1358,7 @@ function _filter_url_settings($form, &$form_state, $filter, $format, $defaults)
'#maxlength' => 4,
'#field_suffix' => t('characters'),
'#description' => t('URLs longer than this number of characters will be truncated to prevent long strings that break formatting. The link itself will be retained; just the text portion of the link will be truncated.'),
+ '#element_validate' => array('element_validate_integer_positive'),
);
return $settings;
}
diff --git a/modules/filter/filter.test b/modules/filter/filter.test
index 2bafd476c..7592d2e8e 100644
--- a/modules/filter/filter.test
+++ b/modules/filter/filter.test
@@ -399,6 +399,18 @@ class FilterAdminTestCase extends DrupalWebTestCase {
$this->assertFieldByName('filters[' . $second_filter . '][weight]', $edit['filters[' . $second_filter . '][weight]'], t('Changes reverted.'));
$this->assertFieldByName('filters[' . $first_filter . '][weight]', $edit['filters[' . $first_filter . '][weight]'], t('Changes reverted.'));
}
+
+ /**
+ * Tests the URL filter settings form is properly validated.
+ */
+ function testUrlFilterAdmin() {
+ // The form does not save with an invalid filter URL length.
+ $edit = array(
+ 'filters[filter_url][settings][filter_url_length]' => $this->randomName(4),
+ );
+ $this->drupalPost('admin/config/content/formats/filtered_html', $edit, t('Save configuration'));
+ $this->assertNoRaw(t('The text format %format has been updated.', array('%format' => 'Filtered HTML')));
+ }
}
class FilterFormatAccessTestCase extends DrupalWebTestCase {
diff --git a/modules/search/search.admin.inc b/modules/search/search.admin.inc
index fda14ee7b..a609485ac 100644
--- a/modules/search/search.admin.inc
+++ b/modules/search/search.admin.inc
@@ -95,7 +95,8 @@ function search_admin_settings($form) {
'#default_value' => variable_get('minimum_word_size', 3),
'#size' => 5,
'#maxlength' => 3,
- '#description' => t('The number of characters a word has to be to be indexed. A lower setting means better search result ranking, but also a larger database. Each search query must contain at least one keyword that is this size (or longer).')
+ '#description' => t('The number of characters a word has to be to be indexed. A lower setting means better search result ranking, but also a larger database. Each search query must contain at least one keyword that is this size (or longer).'),
+ '#element_validate' => array('element_validate_integer_positive'),
);
$form['indexing_settings']['overlap_cjk'] = array(
'#type' => 'checkbox',
diff --git a/modules/search/search.test b/modules/search/search.test
index 26c663e71..eeb6bf21b 100644
--- a/modules/search/search.test
+++ b/modules/search/search.test
@@ -1461,6 +1461,17 @@ class SearchConfigSettingsForm extends DrupalWebTestCase {
$this->assertText(t('The index will be rebuilt'));
$this->drupalGet('admin/config/search/settings');
$this->assertText(t('There is 1 item left to index.'));
+
+ // Test that the form saves with the default values.
+ $this->drupalPost('admin/config/search/settings', array(), t('Save configuration'));
+ $this->assertText(t('The configuration options have been saved.'), 'Form saves with the default values.');
+
+ // Test that the form does not save with an invalid word length.
+ $edit = array(
+ 'minimum_word_size' => $this->randomName(3),
+ );
+ $this->drupalPost('admin/config/search/settings', $edit, t('Save configuration'));
+ $this->assertNoText(t('The configuration options have been saved.'), 'Form does not save with an invalid word length.');
}
/**
diff --git a/modules/user/user.admin.inc b/modules/user/user.admin.inc
index 4789e7e73..1cc2c4a24 100644
--- a/modules/user/user.admin.inc
+++ b/modules/user/user.admin.inc
@@ -413,6 +413,7 @@ function user_admin_settings() {
'#maxlength' => 10,
'#field_suffix' => ' ' . t('KB'),
'#description' => t('Maximum allowed file size for uploaded pictures. Upload size is normally limited only by the PHP maximum post and file upload settings, and images are automatically scaled down to the dimensions specified above.'),
+ '#element_validate' => array('element_validate_integer_positive'),
);
$form['personalization']['pictures']['user_picture_guidelines'] = array(
'#type' => 'textarea',
diff --git a/modules/user/user.test b/modules/user/user.test
index b5b64d65b..abcb0202c 100644
--- a/modules/user/user.test
+++ b/modules/user/user.test
@@ -1132,6 +1132,24 @@ class UserPictureTestCase extends DrupalWebTestCase {
$account = user_load($this->user->uid, TRUE);
return isset($account->picture) ? $account->picture->uri : NULL;
}
+
+ /**
+ * Tests the admin form validates user picture settings.
+ */
+ function testUserPictureAdminFormValidation() {
+ $this->drupalLogin($this->drupalCreateUser(array('administer users')));
+
+ // The default values are valid.
+ $this->drupalPost('admin/config/people/accounts', array(), t('Save configuration'));
+ $this->assertText(t('The configuration options have been saved.'), 'The default values are valid.');
+
+ // The form does not save with an invalid file size.
+ $edit = array(
+ 'user_picture_file_size' => $this->randomName(),
+ );
+ $this->drupalPost('admin/config/people/accounts', $edit, t('Save configuration'));
+ $this->assertNoText(t('The configuration options have been saved.'), 'The form does not save with an invalid file size.');
+ }
}