private function FormsProgrammaticTestCase::submitForm
Helper function used to programmatically submit the form defined in form_test.module with the given values.
Parameters
$values: An array of field values to be submitted.
$valid_input: A boolean indicating whether or not the form submission is expected to be valid.
2 calls to FormsProgrammaticTestCase::submitForm()
- FormsProgrammaticTestCase::testSubmissionWorkflow in drupal-7.x/
modules/ simpletest/ tests/ form.test - Test the programmatic form submission workflow.
- FormsProgrammaticTestCase::testSubmissionWorkflow in drupal-7.x/
modules/ simpletest/ tests/ form.test - Test the programmatic form submission workflow.
Archivo
- drupal-7.x/
modules/ simpletest/ tests/ form.test, line 1512 - Unit tests for the Drupal Form API.
Class
- FormsProgrammaticTestCase
- Test the programmatic form submission behavior.
Código
private function submitForm($values, $valid_input) {
// Programmatically submit the given values.
$form_state = array('values' => $values);
drupal_form_submit('form_test_programmatic_form', $form_state);
// Check that the form returns an error when expected, and vice versa.
$errors = form_get_errors();
$valid_form = empty($errors);
$args = array(
'%values' => print_r($values, TRUE),
'%errors' => $valid_form ? t('None') : implode(' ', $errors),
);
$this->assertTrue($valid_input == $valid_form, format_string('Input values: %values<br/>Validation handler errors: %errors', $args));
// We check submitted values only if we have a valid input.
if ($valid_input) {
// By fetching the values from $form_state['storage'] we ensure that the
// submission handler was properly executed.
$stored_values = $form_state['storage']['programmatic_form_submit'];
foreach ($values as $key => $value) {
$this->assertTrue(isset($stored_values[$key]) && $stored_values[$key] == $value, format_string('Submission handler correctly executed: %stored_key is %stored_value', array('%stored_key' => $key, '%stored_value' => print_r($value, TRUE))));
}
}
}