You are here

function BotchaTestCase::testFormSubmission in BOTCHA Spam Prevention 7.2

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.3 tests/botcha.simpletest.test \BotchaTestCase::testFormSubmission()

File

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

Class

BotchaTestCase
Testing general BOTCHA functionality.

Code

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