You are here

function CaptchaTestCase::testCaptchaDescriptionAfterCommentPreview in CAPTCHA 7

Same name and namespace in other branches
  1. 6.2 captcha.test \CaptchaTestCase::testCaptchaDescriptionAfterCommentPreview()

Test if the CAPTCHA description is only shown if there are challenge widgets to show. For example, when a comment is previewed with correct CAPTCHA answer, a challenge is generated and added to the form but removed in the pre_render phase. The CAPTCHA description should not show up either.

\see testCaptchaSessionReuseOnNodeForms()

File

./captcha.test, line 339
Tests for CAPTCHA module.

Class

CaptchaTestCase

Code

function testCaptchaDescriptionAfterCommentPreview() {

  // Set Test CAPTCHA on comment form.
  captcha_set_form_id_setting(self::COMMENT_FORM_ID, 'captcha/Test');

  // Log in as normal user.
  $this
    ->drupalLogin($this->normal_user);

  // Create a node with comments enabled.
  $node = $this
    ->createNodeWithCommentsEnabled();

  // Preview comment with correct CAPTCHA answer.
  $edit = $this
    ->getCommentFormValues();
  $edit['captcha_response'] = 'Test 123';
  $this
    ->drupalPost('comment/reply/' . $node->nid, $edit, t('Preview'));

  // Check that there is no CAPTCHA after preview.
  $this
    ->assertCaptchaPresence(FALSE);
}