protected function PollTestBase::getChoiceId in Poll 8
Get the Choice ID of a poll.
Parameters
\Drupal\poll\PollInterface $poll: The poll of the choice.
int $delta: The number of the choice.
Return value
int $key Returns the choice ID or an error.
Throws
InvalidArgumentException Throws it if the poll does not have the choice delta.
3 calls to PollTestBase::getChoiceId()
- PollListTest::testViewListPolls in tests/src/ Functional/ PollListTest.php 
- Test if a list of polls is displayed properly.
- PollTokenReplaceTest::testPollTokenReplacement in tests/src/ Functional/ PollTokenReplaceTest.php 
- Creates a poll, then tests the tokens generated from it.
- PollVoteMultilingualTest::testPollVoteMultilingual in tests/src/ Functional/ PollVoteMultilingualTest.php 
- Tests multilingual voting on a poll.
File
- tests/src/ Functional/ PollTestBase.php, line 257 
Class
- PollTestBase
- Defines a base class for testing the Poll module.
Namespace
Drupal\Tests\poll\FunctionalCode
protected function getChoiceId(PollInterface $poll, $delta) {
  $options = $poll
    ->getOptions();
  $keys = array_keys($options);
  foreach ($keys as $id => $key) {
    if ($delta == $id + 1) {
      return $key;
    }
  }
  throw new InvalidArgumentException();
}