You are here

private function FormsElementsTableSelectFunctionalTest::formSubmitHelper in Drupal 7

Helper function for the option check test to submit a form while collecting errors.

Parameters

$form_element: A form element to test.

$edit: An array containing post data.

Return value

An array containing the processed form, the form_state and any errors.

2 calls to FormsElementsTableSelectFunctionalTest::formSubmitHelper()
FormsElementsTableSelectFunctionalTest::testMultipleFalseOptionchecker in modules/simpletest/tests/form.test
Test the whether the option checker gives an error on invalid tableselect values for radios.
FormsElementsTableSelectFunctionalTest::testMultipleTrueOptionchecker in modules/simpletest/tests/form.test
Test the whether the option checker gives an error on invalid tableselect values for checkboxes.

File

modules/simpletest/tests/form.test, line 1059
Unit tests for the Drupal Form API.

Class

FormsElementsTableSelectFunctionalTest
Test the tableselect form element for expected behavior.

Code

private function formSubmitHelper($form, $edit) {
  $form_id = $this
    ->randomName();
  $form_state = form_state_defaults();
  $form['op'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
  );
  $form_state['input'] = $edit;
  $form_state['input']['form_id'] = $form_id;

  // The form token CSRF protection should not interfere with this test,
  // so we bypass it by marking this test form as programmed.
  $form_state['programmed'] = TRUE;
  drupal_prepare_form($form_id, $form, $form_state);
  drupal_process_form($form_id, $form, $form_state);
  $errors = form_get_errors();

  // Clear errors and messages.
  drupal_get_messages();
  form_clear_error();

  // Return the processed form together with form_state and errors
  // to allow the caller lowlevel access to the form.
  return array(
    $form,
    $form_state,
    $errors,
  );
}