You are here

public function BotchaTestCase::testFormSubmission in BOTCHA Spam Prevention 7.3

Same name and namespace in other branches
  1. 6.2 botcha.test \BotchaTestCase::testFormSubmission()
  2. 6.3 tests/botcha.simpletest.test \BotchaTestCase::testFormSubmission()
  3. 7.2 botcha.test \BotchaTestCase::testFormSubmission()

File

tests/botcha.simpletest.test, line 1046
Simpletest-tests for BOTCHA module.

Class

BotchaTestCase
Testing general BOTCHA functionality.

Code

public function testFormSubmission() {
  $forms = array(
    'comment',
  );
  foreach ($forms as $form) {

    // Determine what we expect: whether successful submission or blocked or both.
    foreach ($this
      ->getExpectations() as $should_pass) {
      foreach ($this
        ->getButtonsByForm($form) as $button) {

        // Check some assumptions that are  necessary for this test.
        $this
          ->checkPreConditions($form, $should_pass, $button);

        // Get a form.
        $this
          ->getForm($form);

        // Fill in the form.
        $edit = $this
          ->setFormValues($form, $should_pass);

        // Submit the form.
        $this
          ->postForm($form, $edit, $button);

        // Make sure that we get what expected.
        $this
          ->assertFormSubmission($form, $edit, $should_pass, $button);
      }
    }
  }
}