protected function CaptchaWebTestBase::getCaptchaTokenFromForm in CAPTCHA 8
Get the CAPTCHA token from the current form in the browser.
Parameters
null|string $form_html_id: HTML form id attribute.
Return value
int Captcha token integer.
3 calls to CaptchaWebTestBase::getCaptchaTokenFromForm()
- CaptchaSessionReuseAttackTestCase::testCaptchaSessionReuseAttackDetectionOnCommentPreview in tests/
src/ Functional/ CaptchaSessionReuseAttackTestCase.php - Test captcha attack detection on comment form.
- CaptchaSessionReuseAttackTestCase::testCaptchaSessionReuseAttackDetectionOnLoginForm in tests/
src/ Functional/ CaptchaSessionReuseAttackTestCase.php - Test Captcha attack detection on login form.
- CaptchaSessionReuseAttackTestCase::testCaptchaSessionReuseAttackDetectionOnNodeForm in tests/
src/ Functional/ CaptchaSessionReuseAttackTestCase.php - Test captcha attach detection on node form.
File
- tests/
src/ Functional/ CaptchaWebTestBase.php, line 209
Class
- CaptchaWebTestBase
- Base class for CAPTCHA tests.
Namespace
Drupal\Tests\captcha\FunctionalCode
protected function getCaptchaTokenFromForm($form_html_id = NULL) {
if (!$form_html_id) {
$elements = $this
->xpath('//input[@name="captcha_token"]');
}
else {
$elements = $this
->xpath('//form[@id="' . $form_html_id . '"]//input[@name="captcha_token"]');
}
$element = current($elements);
$captcha_token = (int) $element
->getValue();
return $captcha_token;
}