function PollBlockTest::testRecentBlock in Poll 8
Tests creating, viewing, voting on recent poll block.
File
- tests/
src/ Functional/ PollBlockTest.php, line 29
Class
- PollBlockTest
- Tests the recent poll block.
Namespace
Drupal\Tests\poll\FunctionalCode
function testRecentBlock() {
$poll = $this->poll;
$user = $this->web_user;
// Verify poll appears in a block.
$this
->drupalLogin($user);
$this
->drupalGet('user');
// If a 'block' view not generated, this title would not appear even though
// the choices might.
$this
->assertText($poll
->label());
$options = $poll
->getOptions();
foreach ($options as $option) {
$this
->assertText($option);
}
// Verify we can vote via the block.
$edit = array(
'choice' => '1',
);
$this
->drupalPostForm('user/' . $this->web_user
->id(), $edit, t('Vote'));
$this
->assertText('Your vote has been recorded.');
$this
->assertText('Total votes: 1');
// Close the poll and verify block doesn't appear.
$poll
->close();
$poll
->save();
$this
->drupalGet('user/' . $user
->id());
$this
->assertNoText($poll
->label());
}