You are here

public function ReCaptchaBasicTest::testReCaptchaAdminSettingsForm in reCAPTCHA 7.2

Same name and namespace in other branches
  1. 6.2 recaptcha.test \ReCaptchaBasicTest::testReCaptchaAdminSettingsForm()

Test the reCAPTCHA settings form.

File

./recaptcha.test, line 59
Tests for reCAPTCHA module.

Class

ReCaptchaBasicTest
@file Tests for reCAPTCHA module.

Code

public function testReCaptchaAdminSettingsForm() {
  $this
    ->drupalLogin($this->admin_user);
  $site_key = $this
    ->randomName(40);
  $secret_key = $this
    ->randomName(40);

  // Check form validation.
  $edit['recaptcha_site_key'] = '';
  $edit['recaptcha_secret_key'] = '';
  $edit['recaptcha_tabindex'] = $this
    ->randomName(2);
  $this
    ->drupalPost('admin/config/people/captcha/recaptcha', $edit, t('Save configuration'));
  $this
    ->assertRaw(t('Site key field is required.'), '[testReCaptchaConfiguration]: Empty site key detected.');
  $this
    ->assertRaw(t('Secret key field is required.'), '[testReCaptchaConfiguration]: Empty secret key detected.');
  $this
    ->assertRaw(t('The tabindex must be an integer.'), '[testReCaptchaConfiguration]: Invalid value for tab index detected.');

  // Save form with valid values.
  $edit['recaptcha_site_key'] = $site_key;
  $edit['recaptcha_secret_key'] = $secret_key;
  $edit['recaptcha_tabindex'] = 0;
  $this
    ->drupalPost('admin/config/people/captcha/recaptcha', $edit, t('Save configuration'));
  $this
    ->assertRaw(t('The configuration options have been saved.'), '[testReCaptchaConfiguration]: The configuration options have been saved.');
  $this
    ->assertNoRaw(t('Site key field is required.'), '[testReCaptchaConfiguration]: Site key was not empty.');
  $this
    ->assertNoRaw(t('Secret key field is required.'), '[testReCaptchaConfiguration]: Secret key was not empty.');
  $this
    ->assertNoRaw(t('The tabindex must be an integer.'), '[testReCaptchaConfiguration]: Tab index had a valid input.');
  $this
    ->drupalLogout();
}