public function HCaptchaBasicTest::testHCaptchaAdminSettingsForm in hCaptcha 7
Test the hCaptcha settings form.
File
- ./
hcaptcha.test, line 59 - Tests for hCaptcha module.
Class
- HCaptchaBasicTest
- @file Tests for hCaptcha module.
Code
public function testHCaptchaAdminSettingsForm() {
$this
->drupalLogin($this->admin_user);
$site_key = $this
->randomName(40);
$secret_key = $this
->randomName(40);
// Check form validation.
$edit['hcaptcha_site_key'] = '';
$edit['hcaptcha_secret_key'] = '';
$edit['hcaptcha_tabindex'] = $this
->randomName(2);
$this
->drupalPost('admin/config/people/captcha/hcaptcha', $edit, t('Save configuration'));
$this
->assertRaw(t('Site key field is required.'), '[testHCaptchaConfiguration]: Empty site key detected.');
$this
->assertRaw(t('Secret key field is required.'), '[testHCaptchaConfiguration]: Empty secret key detected.');
$this
->assertRaw(t('The tabindex must be an integer.'), '[testHCaptchaConfiguration]: Invalid value for tab index detected.');
// Save form with valid values.
$edit['hcaptcha_site_key'] = $site_key;
$edit['hcaptcha_secret_key'] = $secret_key;
$edit['hcaptcha_tabindex'] = 0;
$this
->drupalPost('admin/config/people/captcha/hcaptcha', $edit, t('Save configuration'));
$this
->assertRaw(t('The configuration options have been saved.'), '[testHCaptchaConfiguration]: The configuration options have been saved.');
$this
->assertNoRaw(t('Site key field is required.'), '[testHCaptchaConfiguration]: Site key was not empty.');
$this
->assertNoRaw(t('Secret key field is required.'), '[testHCaptchaConfiguration]: Secret key was not empty.');
$this
->assertNoRaw(t('The tabindex must be an integer.'), '[testHCaptchaConfiguration]: Tab index had a valid input.');
$this
->drupalLogout();
}