summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-12-21 21:05:22 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-12-21 21:05:22 +0000
commitbf534a219fec45f05535f4db150cf8b5d052e031 (patch)
tree90dbccae9390cced1bf5a433b6f364645d16af60 /modules
parent3999984bf8d59b4f95f63db5dba044946322b7d8 (diff)
downloadbrdo-bf534a219fec45f05535f4db150cf8b5d052e031.tar.gz
brdo-bf534a219fec45f05535f4db150cf8b5d052e031.tar.bz2
#992928 by das-peter, David_Rothstein: Fixed Command line (Drush) install fails on SQLite (#limit_validation_errors doesn't work for programmatic form submissions)
Diffstat (limited to 'modules')
-rw-r--r--modules/simpletest/tests/form.test9
-rw-r--r--modules/simpletest/tests/form_test.module34
2 files changed, 43 insertions, 0 deletions
diff --git a/modules/simpletest/tests/form.test b/modules/simpletest/tests/form.test
index 3debf4042..b2b822361 100644
--- a/modules/simpletest/tests/form.test
+++ b/modules/simpletest/tests/form.test
@@ -1222,6 +1222,15 @@ class FormsProgrammaticTestCase extends DrupalWebTestCase {
$this->submitForm(array('textfield' => 'dummy value', 'checkboxes' => array(1 => NULL, 2 => 2)), TRUE);
$this->submitForm(array('textfield' => 'dummy value', 'checkboxes' => array(1 => NULL, 2 => NULL)), TRUE);
+ // Test that a programmatic form submission can correctly click a button
+ // that limits validation errors based on user input. Since we do not
+ // submit any values for "textfield" here and the textfield is required, we
+ // only expect form validation to pass when validation is limited to a
+ // different field.
+ $this->submitForm(array('op' => 'Submit with limited validation', 'field_to_validate' => 'all'), FALSE);
+ $this->submitForm(array('op' => 'Submit with limited validation', 'field_to_validate' => 'textfield'), FALSE);
+ $this->submitForm(array('op' => 'Submit with limited validation', 'field_to_validate' => 'field_to_validate'), TRUE);
+
// Restore the current batch status.
$batch = $current_batch;
}
diff --git a/modules/simpletest/tests/form_test.module b/modules/simpletest/tests/form_test.module
index a816caab5..fadd2aa9a 100644
--- a/modules/simpletest/tests/form_test.module
+++ b/modules/simpletest/tests/form_test.module
@@ -1377,6 +1377,7 @@ function form_test_programmatic_form($form, &$form_state) {
'#title' => 'Textfield',
'#type' => 'textfield',
);
+
$form['checkboxes'] = array(
'#type' => 'checkboxes',
'#options' => array(
@@ -1388,6 +1389,39 @@ function form_test_programmatic_form($form, &$form_state) {
'#default_value' => array(1, 2),
);
+ $form['field_to_validate'] = array(
+ '#type' => 'radios',
+ '#title' => 'Field to validate (in the case of limited validation)',
+ '#description' => 'If the form is submitted by clicking the "Submit with limited validation" button, then validation can be limited based on the value of this radio button.',
+ '#options' => array(
+ 'all' => 'Validate all fields',
+ 'textfield' => 'Validate the "Textfield" field',
+ 'field_to_validate' => 'Validate the "Field to validate" field',
+ ),
+ '#default_value' => 'all',
+ );
+
+ // The main submit button for the form.
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => 'Submit',
+ );
+ // A secondary submit button that allows validation to be limited based on
+ // the value of the above radio selector.
+ $form['submit_limit_validation'] = array(
+ '#type' => 'submit',
+ '#value' => 'Submit with limited validation',
+ // Use the same submit handler for this button as for the form itself.
+ // (This must be set explicitly or otherwise the form API will ignore the
+ // #limit_validation_errors property.)
+ '#submit' => array('form_test_programmatic_form_submit'),
+ );
+ if (!empty($form_state['input']['field_to_validate']) && $form_state['input']['field_to_validate'] != 'all') {
+ $form['submit_limit_validation']['#limit_validation_errors'] = array(
+ array($form_state['input']['field_to_validate']),
+ );
+ }
+
return $form;
}