You are here

function BotchaBaseWebTestCase::postForm in BOTCHA Spam Prevention 7.2

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

Post one of predefined forms. Used to unify the process of testing.

4 calls to BotchaBaseWebTestCase::postForm()
BotchaAdminTestCase::testFormUI in ./botcha.test
Tests for creating, modifying and deleting botcha forms.
BotchaAdminTestCase::testRecipebookUI in ./botcha.test
Tests for creating, modifying and deleting recipe books.
BotchaNoResubmitTestCase::setFormValues in ./botcha.test
Helper function to generate a default form values array for any form.
BotchaTestCase::testFormSubmission in ./botcha.test

File

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

Class

BotchaBaseWebTestCase
Base class for BOTCHA tests.

Code

function postForm($form, $edit, $button = NULL, &$parameters = array()) {
  switch ($form) {

    // These ones for testing Form UI.
    case 'addForm':
      $this
        ->debug("Entered %method %case", array(
        '%method' => __METHOD__,
        '%case' => $form,
      ));
      $button = $button ? $button : t('Add');
      $this
        ->drupalPost(NULL, $edit, $button);
      break;
    case 'editForm':
      $this
        ->debug("Entered %method %case", array(
        '%method' => __METHOD__,
        '%case' => $form,
      ));
      $button = $button ? $button : t('Save');
      $this
        ->drupalPost(NULL, $edit, $button);
      break;
    case 'deleteForm':
      $this
        ->debug("Entered %method %case", array(
        '%method' => __METHOD__,
        '%case' => $form,
      ));
      $button = $button ? $button : t('Delete');
      $this
        ->drupalPost(NULL, $edit, $button);
      break;

    // These ones for testing Recipebook UI.
    case 'addRecipebook':
      $this
        ->debug("Entered %method %case", array(
        '%method' => __METHOD__,
        '%case' => $form,
      ));
      $button = $button ? $button : t('Add');
      $this
        ->drupalPost(NULL, $edit, $button);
      break;
    case 'editRecipebook':
      $this
        ->debug("Entered %method %case", array(
        '%method' => __METHOD__,
        '%case' => $form,
      ));
      $button = $button ? $button : t('Save');
      $this
        ->drupalPost(NULL, $edit, $button);
      break;
    case 'deleteRecipebook':
      $this
        ->debug("Entered %method %case", array(
        '%method' => __METHOD__,
        '%case' => $form,
      ));

      // @todo BotchaBaseWebTestCase postForm Case deleteRecipebook.
      break;

    // And these ones are for testing form submissions.
    case 'node':
      $this
        ->debug("Entered %method %case", array(
        '%method' => __METHOD__,
        '%case' => $form,
      ));
      $button = $button ? $button : t('Save');
      $this
        ->drupalPost(NULL, $edit, $button);
      break;
    case 'user_login':
      $this
        ->debug("Entered %method %case", array(
        '%method' => __METHOD__,
        '%case' => $form,
      ));
      $button = $button ? $button : t('Log in');
      $this
        ->drupalPost(NULL, $edit, $button);
      break;
    case 'comment':
    default:
      $this
        ->debug("Entered %method %case", array(
        '%method' => __METHOD__,
        '%case' => $form,
      ));

      // Make sure comments on pages can be saved directly without preview.
      variable_set('comment_preview_page', DRUPAL_OPTIONAL);
      $button = $button ? $button : t('Save');
      $this
        ->drupalPost(NULL, $edit, $button);
      break;
  }
}