You are here

function BotchaAdminTestCase::testFormUI in BOTCHA Spam Prevention 7.2

Tests for creating, modifying and deleting botcha forms.

File

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

Class

BotchaAdminTestCase

Code

function testFormUI() {

  // It is necessary to rebuild menu after changing the setting.
  menu_rebuild();

  // Create a recipe book.
  $id = 'test';
  $title = 'FormUI recipe book';
  $description = 'Created for testing FormUI';
  Botcha::getRecipebook($id)
    ->setTitle($title)
    ->setDescription($description)
    ->save();

  // Log in as admin.
  $this
    ->drupalLogin($this->admin_user);

  // Clean the environment.
  Botcha::clean();
  $forms = array(
    'addForm',
    'editForm',
    'deleteForm',
  );

  // Parameters that need to be passed through methods.
  $parameters = array();
  $parameters['rbid'] = $id;
  foreach ($forms as $form) {
    $this
      ->getForm($form, $parameters);
    $edit = $this
      ->setFormValues($form, NULL, $parameters);
    $this
      ->postForm($form, $edit, NULL, $parameters);
    $this
      ->assertFormSubmission($form, $edit, NULL, NULL, $parameters);
  }
  $this
    ->drupalLogout();
}