You are here

function CaptchaTestCase::testCaptchaSessionReuseOnNodeForms in CAPTCHA 6.2

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

Test if the CAPTCHA session ID is reused when previewing nodes: node preview after correct response should not show CAPTCHA anymore. The preview functionality of comments and nodes works slightly different under the hood. CAPTCHA module should be able to handle both.

\see testCaptchaDescriptionAfterCommentPreview()

File

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

Class

CaptchaTestCase

Code

function testCaptchaSessionReuseOnNodeForms() {

  // Set Test CAPTCHA on page form.
  captcha_set_form_id_setting('page_node_form', 'captcha/Test');

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

  // Page settings to post, with correct CAPTCHA answer.
  $edit = $this
    ->getNodeFormValues();
  $edit['captcha_response'] = 'Test 123';

  // Preview the node
  $this
    ->drupalPost('node/add/page', $edit, t('Preview'));

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