You are here

public function AsciiArtCaptchaTestCase::testAsciiArtCaseInsensitiveValidation in CAPTCHA Pack 8

Testing the case sensitive/insensitive validation.

File

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

Class

AsciiArtCaptchaTestCase
Tests Ascii art CAPTCHA main test case sensitivity.

Namespace

Drupal\ascii_art_captcha\Tests

Code

public function testAsciiArtCaseInsensitiveValidation() {
  $config = $this
    ->config('captcha.settings');

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

  // Test case sensitive posting.
  $config
    ->set('default_validation', CAPTCHA_DEFAULT_VALIDATION_CASE_SENSITIVE);
  $config
    ->save();
  $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).
  $config
    ->set('default_validation', CAPTCHA_DEFAULT_VALIDATION_CASE_INSENSITIVE);
  $config
    ->save();
  $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.');
}