Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-3443915
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
drupal-3443915
Commits
8868a4dc
Commit
8868a4dc
authored
16 years ago
by
Dries Buytaert
Browse files
Options
Downloads
Patches
Plain Diff
- Patch
#296496
by McJim, jpetso: added tests for contact form flood control. Yay.
parent
6b7d5fe2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/contact/contact.test
+16
-0
16 additions, 0 deletions
modules/contact/contact.test
with
16 additions
and
0 deletions
modules/contact/contact.test
+
16
−
0
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
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment