You are here

function CaptchaAdminTestCase::testCaptchaPlacementCacheFlushing in CAPTCHA 6.2

Test the CAPTCHA placement flushing.

File

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

Class

CaptchaAdminTestCase

Code

function testCaptchaPlacementCacheFlushing() {

  // Set CAPTCHA on user register form.
  captcha_set_form_id_setting('user_register', 'captcha/Math');

  // Visit user register form to fill the CAPTCHA placement cache.
  $this
    ->drupalGet('user/register');

  // Check if there is CAPTCHA placement cache.
  $placement_map = variable_get('captcha_placement_map_cache', NULL);
  $this
    ->assertNotNull($placement_map, 'CAPTCHA placement cache should be set.');

  // Flush the cache
  $this
    ->drupalLogin($this->admin_user);
  $this
    ->drupalPost(self::CAPTCHA_ADMIN_PATH, array(), t('Flush the CAPTCHA placement cache'));

  // Check that the placement cache is unset
  $placement_map = variable_get('captcha_placement_map_cache', NULL);
  $this
    ->assertNull($placement_map, 'CAPTCHA placement cache should be unset after flush.');
}