You are here

public function AsciiArtCaptchaTestCase::testAsciiArtCaptchaDescriptionAfterCommentPreview in CAPTCHA Pack 8

Test if the CAPTCHA description is only shown with challenge widgets.

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 also

testCaptchaSessionReuseOnNodeForms()

File

ascii_art_captcha/src/Tests/AsciiArtCaptchaTestCase.php, line 148

Class

AsciiArtCaptchaTestCase
Tests Ascii art CAPTCHA main test case sensitivity.

Namespace

Drupal\ascii_art_captcha\Tests

Code

public function testAsciiArtCaptchaDescriptionAfterCommentPreview() {

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

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

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

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

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