public function WebformSubmissionTestCase::webformSubmissionValidateExecute in Webform 7.4
Same name and namespace in other branches
- 6.3 tests/submission.test \WebformSubmissionTestCase::webformSubmissionValidateExecute()
- 7.3 tests/submission.test \WebformSubmissionTestCase::webformSubmissionValidateExecute()
Execute a validation check for a single component.
1 call to WebformSubmissionTestCase::webformSubmissionValidateExecute()
- WebformSubmissionTestCase::testWebformSubmissionValidate in tests/
WebformSubmissionTestCase.test - Test validation errors on each component that has specialized validation.
File
- tests/
WebformSubmissionTestCase.test, line 359
Class
- WebformSubmissionTestCase
- Webform module submission tests.
Code
public function webformSubmissionValidateExecute() {
$path = drupal_get_path('module', 'webform');
module_load_include('inc', 'webform', 'includes/webform.submissions');
// Create a new Webform test node.
$node = $this
->webformForm();
// Visit the node page.
$this
->drupalGet('node/' . $node->nid);
foreach ($this
->webformComponents() as $key => $component_info) {
if (isset($component_info['error values'])) {
foreach ($component_info['error values'] as $value => $error_message) {
$submission_values = array();
$submission_values["submitted[{$key}]"] = $value;
// Submit our test data.
$this
->drupalPost('node/' . $node->nid, $submission_values, 'Submit', array(), array(), 'webform-client-form-' . $node->nid);
// Confirm that the validation error occurred and the submission did
// not save.
$this
->assertRaw($error_message, t('Validation message properly thrown: "%message".', array(
'%message' => $error_message,
)), t('Webform'));
$this
->assertFalse(preg_match('/sid=([0-9]+)/', $this
->getUrl()), t('Submission not saved.'));
}
}
}
}