You are here

protected function CaptchaWebTestBase::getCaptchaSidFromForm in CAPTCHA 8

Get the CAPTCHA session id from the current form in the browser.

Parameters

null|string $form_html_id: HTML form id attribute.

Return value

int Captcha SID integer.

10 calls to CaptchaWebTestBase::getCaptchaSidFromForm()
CaptchaCacheTest::testCacheTags in tests/src/Functional/CaptchaCacheTest.php
Test the cache tags.
CaptchaPersistenceTest::assertDifferentCsid in tests/src/Functional/CaptchaPersistenceTest.php
Check if message about SID present.
CaptchaPersistenceTest::assertPreservedCsid in tests/src/Functional/CaptchaPersistenceTest.php
Check if Captcha sid present in form.
CaptchaPersistenceTest::testPersistenceAlways in tests/src/Functional/CaptchaPersistenceTest.php
Test persistence always.
CaptchaPersistenceTest::testPersistenceOnlyOnce in tests/src/Functional/CaptchaPersistenceTest.php
Test Persistence "Only once".

... See full list

File

tests/src/Functional/CaptchaWebTestBase.php, line 186

Class

CaptchaWebTestBase
Base class for CAPTCHA tests.

Namespace

Drupal\Tests\captcha\Functional

Code

protected function getCaptchaSidFromForm($form_html_id = NULL) {
  if (!$form_html_id) {
    $elements = $this
      ->xpath('//input[@name="captcha_sid"]');
  }
  else {
    $elements = $this
      ->xpath('//form[@id="' . $form_html_id . '"]//input[@name="captcha_sid"]');
  }
  $element = current($elements);
  $captcha_sid = (int) $element
    ->getValue();
  return $captcha_sid;
}