You are here

function CaptchaTestCase::testCaseInsensitiveValidation in CAPTCHA 6.2

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

File

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

Class

CaptchaTestCase

Code

function testCaseInsensitiveValidation() {

  // 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);

  // Test case sensitive posting.
  variable_set('captcha_default_validation', CAPTCHA_DEFAULT_VALIDATION_CASE_SENSITIVE);
  $this
    ->assertCommentPosting('Test 123', TRUE, 'Case sensitive validation of right casing.');
  $this
    ->assertCommentPosting('test 123', FALSE, 'Case sensitive validation of wrong casing.');
  $this
    ->assertCommentPosting('TEST 123', FALSE, 'Case sensitive validation of wrong casing.');

  // Test case insensitive posting (the default)
  variable_set('captcha_default_validation', CAPTCHA_DEFAULT_VALIDATION_CASE_INSENSITIVE);
  $this
    ->assertCommentPosting('Test 123', TRUE, 'Case insensitive validation of right casing.');
  $this
    ->assertCommentPosting('test 123', TRUE, 'Case insensitive validation of wrong casing.');
  $this
    ->assertCommentPosting('TEST 123', TRUE, 'Case insensitive validation of wrong casing.');
}