public function PollHtmlSpecialCharactersTest::testPollChoice in Poll 8
Test that HTML characters in choices are displayed correctly.
File
- tests/
src/ Functional/ PollHtmlSpecialCharactersTest.php, line 49
Class
- PollHtmlSpecialCharactersTest
- Check that HTML special characters are displayed correctly.
Namespace
Drupal\Tests\poll\FunctionalCode
public function testPollChoice() {
$poll = $this->poll;
// Update the first choice.
$poll->choice[0]->entity
->setChoice($this->special_choice);
$poll->choice[0]->entity
->save();
// View the updated poll.
$this
->drupalGet('poll/' . $this->poll
->id());
$this
->assertResponse(200);
// Verify the updated choice.
$result = $this
->xpath("//div[@id='edit-choice']/div[1]/label/text()");
$this
->assertEqual($this->special_choice, $result[0]
->getText(), 'HTML entities displayed correctly in choice option.');
// Vote.
$this
->drupalPostForm('poll/' . $this->poll
->id(), [
'choice' => 1,
], t('Vote'));
$this
->assertText('Your vote has been recorded.');
$this
->assertText('Total votes: 1');
// Verify the results page.
$result = $this
->xpath('//*[@id="poll-view-form-1"]/div/dl/dt[1]/text()');
$this
->assertEqual($this->special_choice, $result[0]
->getText(), 'HTML entities displayed correctly in vote results.');
}