function PollCreateTestCase::testPollClose in Drupal 7
File
- modules/poll/poll.test, line 238
- Tests for poll.module.
Class
- PollCreateTestCase
Code
function testPollClose() {
$content_user = $this
->drupalCreateUser(array(
'create poll content',
'edit any poll content',
'access content',
));
$vote_user = $this
->drupalCreateUser(array(
'cancel own vote',
'inspect all votes',
'vote on polls',
'access content',
));
$title = $this
->randomName();
$choices = $this
->_generateChoices(7);
$poll_nid = $this
->pollCreate($title, $choices, FALSE);
$this
->drupalLogout();
$this
->drupalLogin($content_user);
$close_edit = array(
'active' => 0,
);
$this
->pollUpdate($poll_nid, $title, $close_edit);
$this
->drupalGet('node/' . $poll_nid);
$elements = $this
->xpath('//input[@id="edit-vote"]');
$this
->assertTrue(empty($elements), "Vote button doesn't appear.");
$this
->drupalGet('poll');
$this
->assertText($title, 'Poll appears in poll list.');
$this
->assertText('closed', 'Poll is closed.');
$open_edit = array(
'active' => 1,
);
$this
->pollUpdate($poll_nid, $title, $open_edit);
$this
->drupalLogout();
$this
->drupalLogin($vote_user);
$vote_edit = array(
'choice' => '1',
);
$this
->drupalPost('node/' . $poll_nid, $vote_edit, t('Vote'));
$this
->assertText('Your vote was recorded.', 'Your vote was recorded.');
$elements = $this
->xpath('//input[@value="Cancel your vote"]');
$this
->assertTrue(isset($elements[0]), "'Cancel your vote' button appears.");
$this
->drupalLogout();
$this
->drupalLogin($content_user);
$close_edit = array(
'active' => 0,
);
$this
->pollUpdate($poll_nid, $title, $close_edit);
$this
->drupalGet('node/' . $poll_nid);
$elements = $this
->xpath('//input[@value="Cancel your vote"]');
$this
->assertTrue(empty($elements), "'Cancel your vote' button no longer appears.");
}