diff --git a/core/modules/poll/poll.module b/core/modules/poll/poll.module index 9b6b28850bd97c03b82515e3f398f34f2f6164a3..c4adcf558082101ce8ef41c28b6e1b5a690bf566 100644 --- a/core/modules/poll/poll.module +++ b/core/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/core/modules/poll/poll.test b/core/modules/poll/poll.test index 557dcec3e341d05f75346e6f46115cdc58f27b87..a4241541b66a8ed0c84e6c7e2a310b5dcac27096 100644 --- a/core/modules/poll/poll.test +++ b/core/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,