You are here

public function TrueFalseTestCase::testQuestionFeedback in Quiz 7.5

Same name and namespace in other branches
  1. 7.6 question_types/truefalse/truefalse.test \TrueFalseTestCase::testQuestionFeedback()

Test incorrect question with all feedbacks on.

File

question_types/truefalse/truefalse.test, line 86
Unit tests for the truefalse Module.

Class

TrueFalseTestCase
Test class for true false questions.

Code

public function testQuestionFeedback() {

  // Login as our privileged user.
  $this
    ->drupalLogin($this->admin);

  // Create the quiz and question.
  $question_node = $this
    ->testCreateQuizQuestion();

  // Link the question.
  $quiz_node = $this
    ->linkQuestionToQuiz($question_node);

  // Login as non-admin.
  $this
    ->drupalLogin($this->user);

  // Take the quiz.
  $this
    ->drupalGet("node/{$quiz_node->nid}/take");
  $this
    ->drupalPost(NULL, array(
    "question[{$question_node->nid}][answer]" => 1,
  ), t('Finish'));
  $this
    ->assertRaw('quiz-score-icon correct');
  $this
    ->assertRaw('quiz-score-icon should');

  // Take the quiz.
  $this
    ->drupalGet("node/{$quiz_node->nid}/take");
  $this
    ->drupalPost(NULL, array(
    "question[{$question_node->nid}][answer]" => 0,
  ), t('Finish'));
  $this
    ->assertRaw('quiz-score-icon incorrect');
  $this
    ->assertRaw('quiz-score-icon should');
}