protected function BotchaBaseWebTestCase::getCommentFormValuesFromForm in BOTCHA Spam Prevention 6
Same name and namespace in other branches
- 6.2 botcha.test \BotchaBaseWebTestCase::getCommentFormValuesFromForm()
- 6.3 tests/botcha.simpletest.test \BotchaBaseWebTestCase::getCommentFormValuesFromForm()
- 7 botcha.test \BotchaBaseWebTestCase::getCommentFormValuesFromForm()
- 7.2 botcha.test \BotchaBaseWebTestCase::getCommentFormValuesFromForm()
- 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 147 
- Tests for BOTCHA module.
Class
- BotchaBaseWebTestCase
- Base class for BOTCHA tests.
Code
protected function getCommentFormValuesFromForm() {
  // Submit the form using the displayed values.
  $displayed = array();
  foreach (array(
    'subject' => "//input[@id='edit-subject']",
    'comment' => "//textarea[@id='edit-comment']",
    'botcha_response' => "//input[@id='edit-botcha-response']",
  ) as $field => $path) {
    $elements = $this
      ->xpath($path);
    $value = isset($elements[0]['value']) ? $elements[0]['value'] : (isset($elements[0][0]) ? $elements[0][0] : FALSE);
    debug($field . ' value=' . $value . '<br>elements=<pre>' . print_r($elements, 1) . '</pre>');
    if (!empty($value)) {
      $displayed[$field] = (string) $value;
    }
  }
  return $displayed;
}