summaryrefslogtreecommitdiff
path: root/modules/poll
diff options
context:
space:
mode:
authorwebchick <webchick@24967.no-reply.drupal.org>2012-01-11 23:27:05 -0500
committerwebchick <webchick@24967.no-reply.drupal.org>2012-01-11 23:27:05 -0500
commitd48aa54c3a795ea2a313d09b0f6c74a702f2ed2d (patch)
treeb340bd318790db44a1732eabff0ced555b727b7f /modules/poll
parent371991597778094590ef37a87f4b57a65225797e (diff)
downloadbrdo-d48aa54c3a795ea2a313d09b0f6c74a702f2ed2d.tar.gz
brdo-d48aa54c3a795ea2a313d09b0f6c74a702f2ed2d.tar.bz2
Issue #1274212 by amateescu, c31ck: Fixed Incorrect order of choices in Poll module.
Diffstat (limited to 'modules/poll')
-rw-r--r--modules/poll/poll.module3
-rw-r--r--modules/poll/poll.test10
2 files changed, 5 insertions, 8 deletions
diff --git a/modules/poll/poll.module b/modules/poll/poll.module
index 48001d099..614bb9240 100644
--- a/modules/poll/poll.module
+++ b/modules/poll/poll.module
@@ -288,9 +288,10 @@ function poll_form($node, &$form_state) {
// Add initial or additional choices.
$existing_delta = $delta;
- $weight++;
for ($delta; $delta < $choice_count; $delta++) {
$key = 'new:' . ($delta - $existing_delta);
+ // Increase the weight of each new choice.
+ $weight++;
$form['choice_wrapper']['choice'][$key] = _poll_choice_form($key, NULL, '', 0, $weight, $choice_count);
}
diff --git a/modules/poll/poll.test b/modules/poll/poll.test
index f34964c3f..f5c93b288 100644
--- a/modules/poll/poll.test
+++ b/modules/poll/poll.test
@@ -101,10 +101,6 @@ class PollTestCase extends DrupalWebTestCase {
}
foreach ($new_choices as $k => $text) {
$edit['choice[new:' . $k . '][chtext]'] = $text;
- // To test poll choice weights, every new choice is sorted in front of
- // existing choices. Existing/already submitted choices should keep their
- // weight.
- $edit['choice[new:' . $k . '][weight]'] = (- $index - $k);
}
return array($edit, count($already_submitted_choices) + count($new_choices));
}
@@ -135,11 +131,11 @@ class PollTestCase extends DrupalWebTestCase {
*/
function assertPollChoiceOrder(array $choices, $index = 0, $preview = FALSE) {
$expected = array();
+ $weight = 0;
foreach ($choices as $id => $label) {
if ($id < $index) {
- // The expected weight of each choice is exactly the negated id.
- // @see PollTestCase::_pollGenerateEdit()
- $weight = -$id;
+ // The expected weight of each choice is higher than the previous one.
+ $weight++;
// Directly assert the weight form element value for this choice.
$this->assertFieldByName('choice[chid:' . $id . '][weight]', $weight, t('Found choice @id with weight @weight.', array(
'@id' => $id,