public function PollKernelTestBase::saveVote in Poll 8
Saves a vote for a given poll.
2 calls to PollKernelTestBase::saveVote()
- PollResultsTest::testPollResults in tests/
src/ Kernel/ PollResultsTest.php - Tests results generation for Polls.
- PollVoteStorageTest::testGetUserVote in tests/
src/ Kernel/ PollVoteStorageTest.php - @covers ::getUserVote
File
- tests/
src/ Kernel/ PollKernelTestBase.php, line 63
Class
- PollKernelTestBase
- Base class for Poll Kernel tests.
Namespace
Drupal\Tests\poll\KernelCode
public function saveVote(PollInterface $poll, $choice_id) {
$options = [];
$options['chid'] = $choice_id;
$options['uid'] = \Drupal::currentUser()
->id();
$options['pid'] = $poll
->id();
$options['hostname'] = \Drupal::request()
->getClientIp();
$options['timestamp'] = \Drupal::time()
->getRequestTime();
/** @var \Drupal\poll\PollVoteStorage $vote_storage */
$vote_storage = \Drupal::service('poll_vote.storage');
$vote_storage
->saveVote($options);
}