You are here

function PollTests::pollCreate in SimpleTest 6

2 calls to PollTests::pollCreate()
PollCreateTest::testPollCreate in tests/poll_module.test
PollVoteTest::testPollVote in tests/poll_module.test

File

tests/poll_module.test, line 5

Class

PollTests

Code

function pollCreate($standalone = TRUE) {
  $this
    ->assertTrue(TRUE, 'Poll create' . $standalone);
  $web_user = $this
    ->drupalCreateUserRolePerm(array(
    'create poll content',
    'access content',
  ));
  $this
    ->drupalLoginUser($web_user);
  $title = $this
    ->randomName();
  $edit = array(
    'title' => $title,
    'choice[0][chtext]' => 'choice 1',
    'choice[1][chtext]' => 'choice 2',
  );
  $this
    ->drupalPost('node/add/poll', $edit, 'More choices');
  $edit = array(
    'title' => $title,
    'choice[0][chtext]' => 'choice 1',
    'choice[1][chtext]' => 'choice 2',
    'choice[2][chtext]' => 'choice 3',
    'choice[3][chtext]' => 'choice 4',
    'choice[4][chtext]' => 'choice 5',
    'choice[5][chtext]' => 'choice 6',
    'choice[6][chtext]' => 'choice 7',
  );
  if ($standalone) {
    $this
      ->drupalPost(NULL, $edit, 'Preview');
    for ($i = 0; $i <= 6; $i++) {
      $bar = theme('poll_bar', $edit['choice[' . $i . '][chtext]'], NULL, 0, FALSE, FALSE);
      $this
        ->assertTrue($bar, "bar {$i} is themed");
      $this
        ->assertWantedRaw($bar, "bar {$i} found in preview");
    }
  }
  $this
    ->drupalPost(NULL, $edit, 'Save');
  $this->nid = preg_replace('/\\D/', '', $this
    ->getUrl());
  $this
    ->assertWantedRaw(t('@type %title has been created.', array(
    '@type' => node_get_types('name', 'poll'),
    '%title' => $title,
  )), 'Poll has been created.');
}