You are here

private function CaptchaPersistenceTest::setUpPersistence in CAPTCHA 8

Set up the persistence and CAPTCHA settings.

Parameters

int $persistence: The persistence value.

4 calls to CaptchaPersistenceTest::setUpPersistence()
CaptchaPersistenceTest::testPersistenceAlways in tests/src/Functional/CaptchaPersistenceTest.php
Test persistence always.
CaptchaPersistenceTest::testPersistenceOnlyOnce in tests/src/Functional/CaptchaPersistenceTest.php
Test Persistence "Only once".
CaptchaPersistenceTest::testPersistencePerFormInstance in tests/src/Functional/CaptchaPersistenceTest.php
Test persistence per form instance.
CaptchaPersistenceTest::testPersistencePerFormType in tests/src/Functional/CaptchaPersistenceTest.php
Test Persistence per form type.

File

tests/src/Functional/CaptchaPersistenceTest.php, line 22

Class

CaptchaPersistenceTest
Tests CAPTCHA Persistence.

Namespace

Drupal\Tests\captcha\Functional

Code

private function setUpPersistence($persistence) {
  $this
    ->drupalLogin($this->adminUser);

  // Set persistence.
  $edit = [
    'persistence' => $persistence,
  ];
  $this
    ->drupalGet(self::CAPTCHA_ADMIN_PATH);
  $this
    ->submitForm($edit, 'Save configuration');

  // Log admin out.
  $this
    ->drupalLogout();

  // Set the Test123 CAPTCHA on user register and comment form.
  // We have to do this with the function captcha_set_form_id_setting()
  // (because the CATCHA admin form does not show the Test123 option).
  // We also have to do this after all usage of the CAPTCHA admin form
  // (because posting the CAPTCHA admin form would set the CAPTCHA to 'none').
  captcha_set_form_id_setting('user_login_form', 'captcha/Test');
  $this
    ->drupalGet('user');
  $this
    ->assertCaptchaPresence(TRUE);
  captcha_set_form_id_setting('user_register_form', 'captcha/Test');
  $this
    ->drupalGet('user/register');
  $this
    ->assertCaptchaPresence(TRUE);
}