You are here

public function QuizTakingTestCase::testQuestionRepeatUntilCorrect in Quiz 7.6

Same name and namespace in other branches
  1. 7.5 tests/QuizTakingTestCase.test \QuizTakingTestCase::testQuestionRepeatUntilCorrect()

Test the repeat until correct behavior. We do not have to test what type of feedback shows here, that is tested elsewhere.

File

tests/QuizTakingTestCase.test, line 22

Class

QuizTakingTestCase

Code

public function testQuestionRepeatUntilCorrect() {
  $this
    ->drupalLogin($this->admin);
  $quiz_node = $this
    ->drupalCreateQuiz(array(
    'repeat_until_correct' => 1,
    'review_options' => array(
      'question' => array(
        'answer_feedback' => 'answer_feedback',
      ),
    ),
  ));
  $question_node = $this
    ->drupalCreateNode(array(
    'type' => 'truefalse',
    'correct_answer' => 1,
  ));
  $this
    ->linkQuestionToQuiz($question_node, $quiz_node);
  $this
    ->drupalLogin($this->user);
  $this
    ->drupalGet("node/{$quiz_node->nid}/take");
  $this
    ->drupalPost(NULL, array(
    "question[{$question_node->nid}][answer]" => 0,
  ), t('Finish'));
  $this
    ->assertText('The answer was incorrect. Please try again.');

  // Check that we are still on the question.
  $this
    ->assertUrl("node/{$quiz_node->nid}/take/1");
  $this
    ->drupalPost(NULL, array(
    "question[{$question_node->nid}][answer]" => 1,
  ), t('Finish'));
  $this
    ->assertNoText('The answer was incorrect. Please try again.');
}