You are here

function BotchaAdminTestCase::testBotchaPlacementCacheFlushing in BOTCHA Spam Prevention 7

Same name and namespace in other branches
  1. 6 botcha.test \BotchaAdminTestCase::testBotchaPlacementCacheFlushing()

Test the BOTCHA placement flushing.

File

./botcha.test, line 687
Tests for BOTCHA module.

Class

BotchaAdminTestCase

Code

function testBotchaPlacementCacheFlushing() {
  $comment_form_id = self::COMMENT_FORM_ID;
  botcha_set_form_id_setting($comment_form_id, 'default');
  variable_set('botcha_administration_mode', TRUE);

  //    $placement_map = variable_get('botcha_placement_map_cache', NULL);
  //    $this->assertNull($placement_map, 'BOTCHA placement cache should be unset.');
  // Create a node with comments enabled.
  $node = $this
    ->createNodeWithCommentsEnabled();

  // Visit comment form of commentable node to fill the BOTCHA placement cache.
  $this
    ->drupalLogin($this->admin_user);
  $this
    ->drupalGet('comment/reply/' . $node->nid);

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

  /* UNUSED, as BOTCHA does not invoke botcha_placement_map_cache on protected forms
      // Set BOTCHA on user register form.
      botcha_set_form_id_setting('user_register_form', 'default');
      // Visit user register form to fill the BOTCHA placement cache.
      $this->drupalGet('user/register');
      // Check if there is BOTCHA placement cache.
      $placement_map = variable_get('botcha_placement_map_cache', NULL);
      $this->assertNotNull($placement_map, 'BOTCHA placement cache should be set.');
  */

  /* UNUSED, as BOTCHA does not have unset placement cache control
      // Flush the cache
      $this->drupalLogin($this->admin_user);
      $this->drupalPost(self::BOTCHA_ADMIN_PATH, array(), t('Flush the BOTCHA placement cache'));
      // Check that the placement cache is unset
      $placement_map = variable_get('botcha_placement_map_cache', NULL);
      $this->assertNull($placement_map, 'BOTCHA placement cache should be unset after flush.');
  */
}