You are here

public function QuizMultichoiceTestCase::testRandomOrder in Quiz 8.6

Same name and namespace in other branches
  1. 8.5 question_types/quiz_multichoice/tests/src/Functional/QuizMultichoiceTestCase.php \Drupal\Tests\quiz_multichoice\Functional\QuizMultichoiceTestCase::testRandomOrder()
  2. 6.x question_types/quiz_multichoice/tests/src/Functional/QuizMultichoiceTestCase.php \Drupal\Tests\quiz_multichoice\Functional\QuizMultichoiceTestCase::testRandomOrder()

Test random order of choices.

@todo I don't know how we would test random questions.

File

question_types/quiz_multichoice/tests/src/Functional/QuizMultichoiceTestCase.php, line 167

Class

QuizMultichoiceTestCase
Test multiple choice questions.

Namespace

Drupal\Tests\quiz_multichoice\Functional

Code

public function testRandomOrder() {
  $this
    ->drupalLogin($this->admin);
  $question = $this
    ->testCreateQuizQuestion(array(
    'choice_random' => 1,
  ));
  $quiz = $this
    ->linkQuestionToQuiz($question);
  $this
    ->drupalLogin($this->user);
  $this
    ->drupalGet("quiz/{$quiz->id()}/take");
  $this
    ->drupalPostForm(NULL, array(
    "question[{$question->id()}][answer][user_answer]" => 1,
  ), t('Finish'));
}