You are here

protected function BotchaBaseWebTestCase::getCommentFormValuesFromForm in BOTCHA Spam Prevention 6.2

Same name and namespace in other branches
  1. 6 botcha.test \BotchaBaseWebTestCase::getCommentFormValuesFromForm()
  2. 6.3 tests/botcha.simpletest.test \BotchaBaseWebTestCase::getCommentFormValuesFromForm()
  3. 7 botcha.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

File

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

Class

BotchaBaseWebTestCase
Base class for BOTCHA tests.

Code

protected function getCommentFormValuesFromForm() {

  // Submit the form using the displayed values.
  // @todo Abstract it.

  //$langcode = LANGUAGE_NONE;
  $displayed = array();
  foreach (array(
    'subject' => "//input[@id='edit-subject']/@value",
    // @todo Abstract it.

    //"comment_body[$langcode][0][value]" => "//textarea[@id='edit-comment-body-$langcode-0-value']",
    'comment' => "//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;
}