Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
f2cbf550
Commit
f2cbf550
authored
Apr 26, 2009
by
Dries
Browse files
- Patch
#440894
by brianV: code style and documentation clean-up.
parent
2a7c00bc
Changes
3
Hide whitespace changes
Inline
Side-by-side
modules/poll/poll.install
View file @
f2cbf550
<?php
// $Id$
/**
* @file
* Install file for poll module.
*/
/**
* Implementation of hook_install().
*/
...
...
modules/poll/poll.module
View file @
f2cbf550
...
...
@@ -249,7 +249,7 @@ function poll_form(&$node, $form_state) {
$delta
=
count
(
$node
->
choice
);
$weight
=
-
$delta
;
foreach
(
$node
->
choice
as
$chid
=>
$choice
)
{
$key
=
'chid:'
.
$chid
;
$key
=
'chid:'
.
$chid
;
$form
[
'choice_wrapper'
][
'choice'
][
$key
]
=
_poll_choice_form
(
$key
,
$choice
[
'chid'
],
$choice
[
'chtext'
],
$choice
[
'chvotes'
],
$choice
[
'weight'
],
$choice_count
);
$weight
=
(
$choice
[
'weight'
]
>
$weight
)
?
$choice
[
'weight'
]
:
$weight
;
}
...
...
@@ -258,7 +258,7 @@ function poll_form(&$node, $form_state) {
// Add initial or additional choices.
$existing_delta
=
$delta
;
for
(
$delta
;
$delta
<
$choice_count
;
$delta
++
)
{
$key
=
'new:'
.
(
$delta
-
$existing_delta
);
$key
=
'new:'
.
(
$delta
-
$existing_delta
);
$form
[
'choice_wrapper'
][
'choice'
][
$key
]
=
_poll_choice_form
(
$key
,
NULL
,
''
,
0
,
$weight
,
$choice_count
);
}
...
...
@@ -537,7 +537,7 @@ function poll_delete($node) {
->
execute
();
db_delete
(
'poll_vote'
)
->
condition
(
'nid'
,
$node
->
nid
)
->
execute
();
->
execute
();
}
/**
...
...
@@ -751,7 +751,7 @@ function theme_poll_choices($form) {
);
// Add any additional classes set on the row.
$row
[
'class'
]
.
=
isset
(
$form
[
$key
][
'#attributes'
][
'class'
])
?
' '
.
$form
[
$key
][
'#attributes'
][
'class'
]
:
''
;
$row
[
'class'
]
.
=
isset
(
$form
[
$key
][
'#attributes'
][
'class'
])
?
' '
.
$form
[
$key
][
'#attributes'
][
'class'
]
:
''
;
$rows
[]
=
$row
;
}
...
...
modules/poll/poll.test
View file @
f2cbf550
<?php
// $Id$
/**
* @file
* Tests for the poll module.
*/
class
PollTestCase
extends
DrupalWebTestCase
{
/**
...
...
@@ -25,7 +30,7 @@ class PollTestCase extends DrupalWebTestCase {
if
(
count
(
$choices
)
>
2
)
{
// Re-submit the form while the choices are all in
while
(
$index
<
count
(
$choices
))
{
while
(
$index
<
count
(
$choices
))
{
$this
->
drupalPost
(
NULL
,
$edit
,
t
(
'More choices'
));
list
(
$edit
,
$index
)
=
$this
->
_pollGenerateEdit
(
$title
,
$choices
,
$index
);
}
...
...
@@ -33,7 +38,7 @@ class PollTestCase extends DrupalWebTestCase {
if
(
$test_preview
)
{
$this
->
drupalPost
(
NULL
,
$edit
,
t
(
'Preview'
));
foreach
(
$choices
as
$k
=>
$choice_text
)
{
foreach
(
$choices
as
$k
=>
$choice_text
)
{
$this
->
assertRaw
(
$choice_text
,
t
(
'Choice @choice found was in preview.'
,
array
(
'@choice'
=>
$k
)));
}
list
(
$edit
,
$index
)
=
$this
->
_pollGenerateEdit
(
$title
,
$choices
,
$index
);
...
...
@@ -55,10 +60,10 @@ class PollTestCase extends DrupalWebTestCase {
$edit
=
array
(
'title'
=>
$title
);
foreach
(
$already_submitted_choices
as
$k
=>
$text
)
{
foreach
(
$already_submitted_choices
as
$k
=>
$text
)
{
$edit
[
'choice[chid:'
.
$k
.
'][chtext]'
]
=
$text
;
}
foreach
(
$new_choices
as
$k
=>
$text
)
{
foreach
(
$new_choices
as
$k
=>
$text
)
{
$edit
[
'choice[new:'
.
$k
.
'][chtext]'
]
=
$text
;
}
return
array
(
$edit
,
count
(
$already_submitted_choices
)
+
count
(
$new_choices
));
...
...
@@ -66,7 +71,7 @@ class PollTestCase extends DrupalWebTestCase {
function
_generateChoices
(
$count
=
7
)
{
$choices
=
array
();
for
(
$i
=
1
;
$i
<=
$count
;
$i
++
)
{
for
(
$i
=
1
;
$i
<=
$count
;
$i
++
)
{
$choices
[]
=
$this
->
randomName
();
}
return
$choices
;
...
...
@@ -112,10 +117,10 @@ class PollVoteTestCase extends PollTestCase {
$this
->
drupalLogin
(
$web_user
);
// Record a vote for the first choice.
$edit
=
array
(
$edit
=
array
(
'choice'
=>
'1'
,
);
$this
->
drupalPost
(
'node/'
.
$poll_nid
,
$edit
,
t
(
'Vote'
));
$this
->
drupalPost
(
'node/'
.
$poll_nid
,
$edit
,
t
(
'Vote'
));
$this
->
assertText
(
'Your vote was recorded.'
,
'Your vote was recorded.'
);
$this
->
drupalGet
(
"node/
$poll_nid
/votes"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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