Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
8868a4dc
Commit
8868a4dc
authored
Sep 16, 2008
by
Dries Buytaert
Browse files
- Patch
#296496
by McJim, jpetso: added tests for contact form flood control. Yay.
parent
6b7d5fe2
Changes
1
Hide whitespace changes
Inline
Side-by-side
modules/contact/contact.test
View file @
8868a4dc
...
...
@@ -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
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment