You are here

public function PollHtmlSpecialCharactersTest::testPollQuestion in Poll 8

Test that HTML characters in the title are displayed correctly.

File

tests/src/Functional/PollHtmlSpecialCharactersTest.php, line 30

Class

PollHtmlSpecialCharactersTest
Check that HTML special characters are displayed correctly.

Namespace

Drupal\Tests\poll\Functional

Code

public function testPollQuestion() {

  // Verify user can view poll.
  $this
    ->drupalGet('poll/' . $this->poll
    ->id());
  $this
    ->assertResponse(200);

  // Verify the page title.
  $result = $this
    ->xpath("//div[contains(concat(' ', @class, ' '), ' block-page-title-block ')]/h1");
  $this
    ->assertEqual($this->page_title, $result[0]
    ->getText(), 'HTML entities displayed correctly in page title.');

  // Verify the poll title is escaped correctly in the poll results.
  $this
    ->drupalPostForm('poll/' . $this->poll
    ->id(), [
    'choice' => 1,
  ], t('Vote'));
  $this
    ->assertText('Your vote has been recorded.');
  $this
    ->drupalGet('polls');
  $this
    ->assertSession()
    ->elementTextContains('css', 'h3.poll-question', $this->page_title);
}