function PollTestBase::_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 PollTestBase::_generateChoices().

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

Return value

An indexed array containing:

1 call to PollTestBase::_pollGenerateEdit()
PollTestBase::pollCreate in drupal/core/modules/poll/lib/Drupal/poll/Tests/PollTestBase.php
Creates a poll.

File

drupal/core/modules/poll/lib/Drupal/poll/Tests/PollTestBase.php, line 105
Definition of Drupal\poll\Tests\PollTestBase.

Class

PollTestBase
Defines a base class for testing the Poll module.

Namespace

Drupal\poll\Tests

Code

function _pollGenerateEdit($title, array $choices, $index = 0) {
  $max_new_choices = $index == 0 ? 2 : 1;
  $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),
  );
}