You are here

public function MatchingTestCase::testChoicePenalty in Quiz 7.5

Same name and namespace in other branches
  1. 7.6 question_types/matching/matching.test \MatchingTestCase::testChoicePenalty()

Test if the penalty system for guessing wrong work.

File

question_types/matching/matching.test, line 119
Unit tests for the matching Module.

Class

MatchingTestCase
Test class for matching questions.

Code

public function testChoicePenalty() {
  $quiz_node = $this
    ->drupalCreateQuiz(array(
    'review_options' => array(
      'end' => drupal_map_assoc(array(
        'answer_feedback',
        'score',
      )),
    ),
  ));
  $question_node = $this
    ->testCreateQuizQuestion();
  $question_node->choice_penalty = 1;
  node_save($question_node);

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

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

  // Test penalty.
  $this
    ->drupalGet("node/{$quiz_node->nid}/take");
  $this
    ->drupalPost(NULL, array(
    "question[{$question_node->nid}][answer][4]" => 4,
    "question[{$question_node->nid}][answer][5]" => 5,
    "question[{$question_node->nid}][answer][6]" => 4,
  ), t('Finish'));
  $this
    ->assertText('You got 1 of 3 possible points.');
}