You are here

protected function BotchaNoResubmitTestCase::setFormValues in BOTCHA Spam Prevention 7.2

Same name and namespace in other branches
  1. 6.2 botcha.test \BotchaNoResubmitTestCase::setFormValues()
  2. 6.3 tests/botcha.simpletest.test \BotchaNoResubmitTestCase::setFormValues()
  3. 7.3 tests/botcha.simpletest.test \BotchaNoResubmitTestCase::setFormValues()

Helper function to generate a default form values array for any form.

Overrides BotchaBaseWebTestCase::setFormValues

File

./botcha.test, line 1158
Tests for BOTCHA module.

Class

BotchaNoResubmitTestCase

Code

protected function setFormValues($form, $should_pass) {
  $edit = parent::setFormValues($form, $should_pass);
  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);

      // 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;
}