You are here

public function PollResultsTest::testPollResults in Poll 8

Tests results generation for Polls.

File

tests/src/Kernel/PollResultsTest.php, line 17

Class

PollResultsTest
Tests results generation for Polls.

Namespace

Drupal\Tests\poll\Kernel

Code

public function testPollResults() {
  $poll = $this
    ->createPoll();
  $this
    ->saveVote($poll, $poll
    ->get('choice')->target_id);
  $poll_view_form = new PollViewForm();
  $poll_results = $poll_view_form
    ->showPollResults($poll);

  /** @var \Drupal\poll\PollVoteStorage $vote_storage */
  $vote_storage = \Drupal::service('poll_vote.storage');
  $user_vote = $vote_storage
    ->getUserVote($poll);
  $this
    ->assertEquals($user_vote['chid'], $poll_results['#vote']);
}