function FloodFunctionalTest::testCleanUp

Test flood control mechanism clean-up.

File

drupal/modules/system/system.test, line 2613
Tests for system.module.

Class

FloodFunctionalTest
Functional tests for the flood control mechanism.

Code

function testCleanUp() {
  $threshold = 1;
  $window_expired = -1;
  $name = 'flood_test_cleanup';

  // Register expired event.
  flood_register_event($name, $window_expired);

  // Verify event is not allowed.
  $this
    ->assertFalse(flood_is_allowed($name, $threshold));

  // Run cron and verify event is now allowed.
  $this
    ->cronRun();
  $this
    ->assertTrue(flood_is_allowed($name, $threshold));

  // Register unexpired event.
  flood_register_event($name);

  // Verify event is not allowed.
  $this
    ->assertFalse(flood_is_allowed($name, $threshold));

  // Run cron and verify event is still not allowed.
  $this
    ->cronRun();
  $this
    ->assertFalse(flood_is_allowed($name, $threshold));
}