You are here

protected function BotchaBaseWebTestCase::getCommentFormValuesFromForm in BOTCHA Spam Prevention 7

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

Helper function to get form values array from comment form

2 calls to BotchaBaseWebTestCase::getCommentFormValuesFromForm()
BotchaSessionReuseAttackTestCase::testBotchaSessionReuseAttackDetectionOnCommentPreview in ./botcha.test
BotchaTestCase::testBotchaResubmit in ./botcha.test
Test if BOTCHA is applied correctly when failing first and then resubmitting comments: comment form should have BOTCHA again and pass correct submission. (We use to fail BOTCHA as it is impossible to fail comment form on its own)

File

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

Class

BotchaBaseWebTestCase
Base class for BOTCHA tests.

Code

protected function getCommentFormValuesFromForm() {

  // Submit the form using the displayed values.
  $langcode = LANGUAGE_NONE;
  $displayed = array();
  foreach (array(
    'subject' => "//input[@id='edit-subject']/@value",
    "comment_body[{$langcode}][0][value]" => "//textarea[@id='edit-comment-body-{$langcode}-0-value']",
    'botcha_response' => "//input[@id='edit-botcha-response']/@value",
  ) as $field => $path) {
    $value = current($this
      ->xpath($path));
    if (!empty($value)) {
      $displayed[$field] = (string) $value;
    }
  }
  return $displayed;
}