protected function BotchaNoResubmitTestCase::setFormValues in BOTCHA Spam Prevention 6.3
Same name and namespace in other branches
- 6.2 botcha.test \BotchaNoResubmitTestCase::setFormValues()
- 7.2 botcha.test \BotchaNoResubmitTestCase::setFormValues()
- 7.3 tests/botcha.simpletest.test \BotchaNoResubmitTestCase::setFormValues()
Helper function to generate a default form values array for any form.
Overrides BotchaBaseWebTestCase::setFormValues
File
- tests/
botcha.simpletest.test, line 1235 - Simpletest-tests for BOTCHA module.
Class
Code
protected function setFormValues($form, $should_pass, &$parameters = array()) {
$edit = parent::setFormValues($form, $should_pass, $parameters);
switch ($should_pass) {
case FALSE:
// Get form_build_id of the form (to simulate resubmit).
$form_build_id = $this
->getFormBuildIdFromForm($form);
// Submit a form once.
$this
->postForm($form, $edit);
// Make sure it passes.
parent::assertFormSubmission($form, $edit, TRUE);
// Get new form.
$this
->getForm($form);
//$edit = parent::setFormValues($form, $should_pass, $parameters);
// Set form_build_id of the current form to stored value (to simulate resubmit).
$edit['form_build_id'] = $form_build_id;
break;
case TRUE:
default:
// Everything is done already.
break;
}
return $edit;
}