summaryrefslogtreecommitdiff
path: root/modules/system/system.test
diff options
context:
space:
mode:
Diffstat (limited to 'modules/system/system.test')
-rw-r--r--modules/system/system.test38
1 files changed, 38 insertions, 0 deletions
diff --git a/modules/system/system.test b/modules/system/system.test
index 4f684e876..3f66d677b 100644
--- a/modules/system/system.test
+++ b/modules/system/system.test
@@ -1503,3 +1503,41 @@ class UpdateScriptFunctionalTest extends DrupalWebTestCase {
$this->assertResponse(200);
}
}
+
+/**
+ * Functional tests for the flood control mechanism.
+ */
+class FloodFunctionalTest extends DrupalWebTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Flood control mechanism',
+ 'description' => 'Functional tests for the flood control mechanism.',
+ 'group' => 'System',
+ );
+ }
+
+ /**
+ * Test flood control mechanism clean-up.
+ */
+ 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));
+ }
+}