function PollTestCase::_pollGenerateEdit

Generates POST values for the poll node form, specifically poll choices.

Parameters

$title: The title for the poll node.

$choices: An array containing poll choices, as generated by PollTestCase::_generateChoices().

$index: (optional) The amount/number of already submitted poll choices. Defaults to 0.

Return value

An indexed array containing:

  • The generated POST values, suitable for DrupalWebTestCase::drupalPost().
  • The number of poll choices contained in 'edit', for potential re-usage in subsequent invocations of this function.
1 call to PollTestCase::_pollGenerateEdit()
PollTestCase::pollCreate in drupal/modules/poll/poll.test
Creates a poll.

File

drupal/modules/poll/poll.test, line 91
Tests for poll.module.

Class

PollTestCase
@file Tests for poll.module.

Code

function _pollGenerateEdit($title, array $choices, $index = 0) {
  $max_new_choices = $index == 0 ? 2 : 5;
  $already_submitted_choices = array_slice($choices, 0, $index);
  $new_choices = array_values(array_slice($choices, $index, $max_new_choices));
  $edit = array(
    'title' => $title,
  );
  foreach ($already_submitted_choices as $k => $text) {
    $edit['choice[chid:' . $k . '][chtext]'] = $text;
  }
  foreach ($new_choices as $k => $text) {
    $edit['choice[new:' . $k . '][chtext]'] = $text;
  }
  return array(
    $edit,
    count($already_submitted_choices) + count($new_choices),
  );
}