diff options
author | Dries Buytaert <dries@buytaert.net> | 2008-09-16 18:18:02 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2008-09-16 18:18:02 +0000 |
commit | 8868a4dc6a1b4451bbf8627b1de51f10218294c3 (patch) | |
tree | a8aa6cf57b5be127cf4ae05d664851be94c76c7f | |
parent | 6b7d5fe21bce972bb0e0fbd5b0c75d1e215b9e8d (diff) | |
download | brdo-8868a4dc6a1b4451bbf8627b1de51f10218294c3.tar.gz brdo-8868a4dc6a1b4451bbf8627b1de51f10218294c3.tar.bz2 |
- Patch #296496 by McJim, jpetso: added tests for contact form flood control. Yay.
-rw-r--r-- | modules/contact/contact.test | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/modules/contact/contact.test b/modules/contact/contact.test index b6328fc15..12ef2ee90 100644 --- a/modules/contact/contact.test +++ b/modules/contact/contact.test @@ -264,8 +264,10 @@ class ContactPersonalTestCase extends DrupalWebTestCase { $this->drupalLogin($admin_user); // Enable the personal contact form. + $flood_control = 3; $edit = array(); $edit['contact_default_status'] = TRUE; + $edit['contact_hourly_threshold'] = $flood_control; $this->drupalPost('admin/build/contact/settings', $edit, t('Save configuration')); $this->assertText(t('The configuration options have been saved.'), t('Setting successfully saved.')); @@ -287,6 +289,20 @@ class ContactPersonalTestCase extends DrupalWebTestCase { $this->drupalPost(NULL, $edit, t('Send e-mail')); $this->assertText(t('The message has been sent.'), t('Message sent.')); + // Clear flood table in preparation for flood test and allow other checks to complete. + $this->assertTrue(db_query('DELETE FROM {flood}'), t('Flood table emptied.')); + + // Submit contact form with correct values and check flood interval. + for ($i = 0; $i < $flood_control; $i++) { + $this->drupalGet('user/' . $web_user2->uid . '/contact'); + $this->drupalPost(NULL, $edit, t('Send e-mail')); + $this->assertText(t('The message has been sent.'), t('Message sent.')); + } + + // Submit contact form one over limit. + $this->drupalGet('user/' . $web_user2->uid . '/contact'); + $this->assertRaw(t('You cannot send more than %number messages per hour. Please try again later.', array('%number' => $flood_control)), t('Message threshold reached.')); + $this->drupalLogout(); $this->drupalLogin($admin_user); |