You are here

protected function OpignoPollAppWebTestCase::createPoll in Opigno Poll App 7

Create a new poll.

Parameters

string $title = NULL:

int $gid = NULL:

array $choices = array('Choice 1', 'Choice 2'):

bool $open = TRUE:

Return value

object

2 calls to OpignoPollAppWebTestCase::createPoll()
OpignoPollAppWebTestCase::testAccessControl in tests/OpignoPollAppWebTestCase.test
Test permissions.
OpignoPollAppWebTestCase::testDisplays in tests/OpignoPollAppWebTestCase.test
Test default views and displays.

File

tests/OpignoPollAppWebTestCase.test, line 222
Defines the unit tests for Opigno Poll.

Class

OpignoPollAppWebTestCase
@file Defines the unit tests for Opigno Poll.

Code

protected function createPoll($title = NULL, $gid = NULL, $choices = array(
  'Choice 1',
  'Choice 2',
), $open = TRUE) {
  $settings = array(
    'type' => 'poll',
    'title' => $title ? $title : $this
      ->randomName(8),
    'active' => (int) $open,
    'runtime' => 0,
  );
  if (!empty($gid)) {
    $settings['og_group_ref'][LANGUAGE_NONE][0]['target_id'] = $gid;
  }
  foreach ($choices as $i => $choice) {
    $settings['choice'][] = array(
      'chtext' => $choice,
      'chvotes' => 0,
      'weight' => 0,
    );
  }
  $node = $this
    ->drupalCreateNode($settings);
  $this
    ->verbose(print_r($node, 1));
  $this
    ->assertTrue(!empty($node->nid), 'Created a new course.');
  $this
    ->drupalGet('node/' . $node->nid);
  $this
    ->assertText($choice, 'Added last choice correctly');
  return node_load($node->nid, NULL, TRUE);

  // Refresh choices.
}