| 7 poll.test | PollJSAddChoice::testAddChoice() |
| 8 poll.test | PollJSAddChoice::testAddChoice() |
Test adding a new choice.
File
- modules/
poll/ poll.test, line 453 - Tests for poll.module.
Code
function testAddChoice() {
$web_user = $this->drupalCreateUser(array('create poll content', 'access content'));
$this->drupalLogin($web_user);
$this->drupalGet('node/add/poll');
$edit = array(
"title" => $this->randomName(),
'choice[new:0][chtext]' => $this->randomName(),
'choice[new:1][chtext]' => $this->randomName(),
);
// Press 'add choice' button through Ajax, and place the expected HTML result
// as the tested content.
$commands = $this->drupalPostAJAX(NULL, $edit, array('op' => t('More choices')));
$this->content = $commands[1]['data'];
$this->assertFieldByName('choice[chid:0][chtext]', $edit['choice[new:0][chtext]'], t('Field !i found', array('!i' => 0)));
$this->assertFieldByName('choice[chid:1][chtext]', $edit['choice[new:1][chtext]'], t('Field !i found', array('!i' => 1)));
$this->assertFieldByName('choice[new:0][chtext]', '', t('Field !i found', array('!i' => 2)));
}
Login or register to post comments