Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
665a0c33
Commit
665a0c33
authored
Jun 23, 2010
by
Dries Buytaert
Browse files
Options
Downloads
Patches
Plain Diff
- Patch
#295990
by mr.baileys, lilou: testingParty08: Poll autoexpire.
parent
12c2b192
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/poll/poll.test
+64
-1
64 additions, 1 deletion
modules/poll/poll.test
with
64 additions
and
1 deletion
modules/poll/poll.test
+
64
−
1
View file @
665a0c33
...
...
@@ -19,7 +19,7 @@ class PollTestCase extends DrupalWebTestCase {
function
pollCreate
(
$title
,
$choices
,
$test_preview
=
TRUE
)
{
$this
->
assertTrue
(
TRUE
,
'Create a poll'
);
$web_user
=
$this
->
drupalCreateUser
(
array
(
'create poll content'
,
'access content'
));
$web_user
=
$this
->
drupalCreateUser
(
array
(
'create poll content'
,
'access
content'
,
'edit own poll
content'
));
$this
->
drupalLogin
(
$web_user
);
// Get the form first to initialize the state of the internal browser
...
...
@@ -578,3 +578,66 @@ class PollTokenReplaceTestCase extends PollTestCase {
}
}
}
class
PollExpirationTestCase
extends
PollTestCase
{
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'Poll expiration'
,
'description'
=>
'Test the poll auto-expiration logic.'
,
'group'
=>
'Poll'
,
);
}
function
setUp
()
{
parent
::
setUp
(
'poll'
);
}
function
testAutoExpire
()
{
// Set up a poll.
$title
=
$this
->
randomName
();
$choices
=
$this
->
_generateChoices
(
2
);
$poll_nid
=
$this
->
pollCreate
(
$title
,
$choices
,
FALSE
);
$this
->
assertTrue
(
$poll_nid
,
t
(
'Poll for auto-expire test created.'
),
t
(
'Poll'
));
// Visit the poll edit page and verify that by default, expiration
// is set to unlimited.
$this
->
drupalGet
(
"node/
$poll_nid
/edit"
);
$this
->
assertField
(
'runtime'
,
t
(
'Poll expiration setting found.'
),
t
(
'Poll'
));
$elements
=
$this
->
xpath
(
'//select[@id="edit-runtime"]/option[@selected="selected"]'
);
$this
->
assertTrue
(
isset
(
$elements
[
0
][
'value'
])
&&
$elements
[
0
][
'value'
]
==
0
,
t
(
'Poll expiration set to unlimited.'
),
t
(
'Poll'
));
// Set the expiration to one week.
$edit
=
array
();
$poll_expiration
=
604800
;
// One week.
$edit
[
'runtime'
]
=
$poll_expiration
;
$this
->
drupalPost
(
NULL
,
$edit
,
t
(
'Save'
));
$this
->
assertRaw
(
t
(
'Poll %title has been updated.'
,
array
(
'%title'
=>
$title
)),
t
(
'Poll expiration settings saved.'
),
t
(
'Poll'
));
// Make sure that the changed expiration settings is kept.
$this
->
drupalGet
(
"node/
$poll_nid
/edit"
);
$elements
=
$this
->
xpath
(
'//select[@id="edit-runtime"]/option[@selected="selected"]'
);
$this
->
assertTrue
(
isset
(
$elements
[
0
][
'value'
])
&&
$elements
[
0
][
'value'
]
==
$poll_expiration
,
t
(
'Poll expiration set to unlimited.'
),
t
(
'Poll'
));
// Force a cron run. Since the expiration date has not yet been reached,
// the poll should remain active.
drupal_cron_run
();
$this
->
drupalGet
(
"node/
$poll_nid
/edit"
);
$elements
=
$this
->
xpath
(
'//input[@id="edit-active-1"]'
);
$this
->
assertTrue
(
isset
(
$elements
[
0
])
&&
!
empty
(
$elements
[
0
][
'checked'
]),
t
(
'Poll is still active.'
),
t
(
'Poll'
));
// Test expiration. Since REQUEST_TIME is a constant and we don't
// want to keep SimpleTest waiting until the moment of expiration arrives,
// we forcibly change the expiration date in the database.
$created
=
db_query
(
'SELECT created FROM {node} WHERE nid = :nid'
,
array
(
':nid'
=>
$poll_nid
))
->
fetchField
();
db_update
(
'node'
)
->
fields
(
array
(
'created'
=>
$created
-
(
$poll_expiration
*
1.01
)))
->
condition
(
'nid'
,
$poll_nid
)
->
execute
();
// Run cron and verify that the poll is now marked as "closed".
drupal_cron_run
();
$this
->
drupalGet
(
"node/
$poll_nid
/edit"
);
$elements
=
$this
->
xpath
(
'//input[@id="edit-active-0"]'
);
$this
->
assertTrue
(
isset
(
$elements
[
0
])
&&
!
empty
(
$elements
[
0
][
'checked'
]),
t
(
'Poll has expired.'
),
t
(
'Poll'
));
}
}
\ No newline at end of file
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