public function WebformTestCase::webformPost in Webform 7.4
Generate a list of all values that would result in a valid submission.
Parameters
$input_values: An array of input values keyed by the component form key. If none are specified, the defaults will be pulled from webformComponents().
2 calls to WebformTestCase::webformPost()
- WebformConditionalsTestCase::webformTestConditionalComponent in tests/
WebformConditionalsTestCase.test - Assembles a test node for checking if conditional properties are respected.
- WebformSubmissionTestCase::webformSubmissionExecute in tests/
WebformSubmissionTestCase.test - Execute the submission test.
File
- tests/
WebformTestCase.test, line 1038
Class
- WebformTestCase
- Webform module tests.
Code
public function webformPost($input_values = NULL) {
$edit = array();
if (empty($input_values)) {
$input_values = array();
foreach ($this
->webformComponents() as $key => $component_info) {
$input_values[$key] = $component_info['sample values'];
}
}
foreach ($input_values as $key => $values) {
if (is_array($values)) {
foreach ($values as $subkey => $value) {
$edit["submitted[{$key}][{$subkey}]"] = $value;
}
}
elseif ($values != NULL) {
$value = $values;
// Multiple selects have a funky extra empty bracket in the name.
$extra = $key == 'select_multiple' ? '[]' : '';
$edit["submitted[{$key}]{$extra}"] = $value;
}
}
return $edit;
}