function ReCaptchaBasicTest::testReCaptchaAdminSettingsForm in reCAPTCHA 6.2
Same name and namespace in other branches
- 7.2 recaptcha.test \ReCaptchaBasicTest::testReCaptchaAdminSettingsForm()
Test the reCAPTCHA settings form.
File
- ./
recaptcha.test, line 58 - Tests for reCAPTCHA module.
Class
- ReCaptchaBasicTest
- @file Tests for reCAPTCHA module.
Code
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/user/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/user/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();
}