You are here

function TrueFalseTestCase::testQuestionFeedback in Quiz 7.6

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

File

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

Class

TrueFalseTestCase
Test class for true false questions.

Code

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);

  // Test incorrect question with all feedbacks on.
  // 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');
}