You are here

private function CaptchaPersistenceTestCase::setUpPersistence in CAPTCHA 7

Same name and namespace in other branches
  1. 6.2 captcha.test \CaptchaPersistenceTestCase::setUpPersistence()

Set up the persistence and CAPTCHA settings.

Parameters

int $persistence the persistence value.:

4 calls to CaptchaPersistenceTestCase::setUpPersistence()
CaptchaPersistenceTestCase::testPersistenceAlways in ./captcha.test
CaptchaPersistenceTestCase::testPersistenceOnlyOnce in ./captcha.test
CaptchaPersistenceTestCase::testPersistencePerFormInstance in ./captcha.test
CaptchaPersistenceTestCase::testPersistencePerFormType in ./captcha.test

File

./captcha.test, line 798
Tests for CAPTCHA module.

Class

CaptchaPersistenceTestCase

Code

private function setUpPersistence($persistence) {

  // Log in as admin
  $this
    ->drupalLogin($this->admin_user);

  // Set persistence.
  $edit = array(
    'captcha_persistence' => $persistence,
  );
  $this
    ->drupalPost(self::CAPTCHA_ADMIN_PATH, $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', '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);
}