You are here

public function MatchingTestCase::testEditQuestionResponse in Quiz 7.5

Test that the question response can be edited.

File

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

Class

MatchingTestCase
Test class for matching questions.

Code

public function testEditQuestionResponse() {

  // Create & link a question.
  $question_node = $this
    ->testCreateQuizQuestion();
  $quiz_node = $this
    ->linkQuestionToQuiz($question_node);
  $question_node2 = $this
    ->testCreateQuizQuestion();
  $this
    ->linkQuestionToQuiz($question_node2, $quiz_node);

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

  // Take the quiz.
  $this
    ->drupalGet("node/{$quiz_node->nid}/take");

  // Test editing a question.
  $this
    ->drupalGet("node/{$quiz_node->nid}/take");
  $this
    ->drupalGet("node/{$quiz_node->nid}/take/1");
  $this
    ->drupalPost(NULL, array(
    "question[{$question_node->nid}][answer][1]" => 1,
  ), t('Next'));
  $this
    ->drupalGet("node/{$quiz_node->nid}/take/1");
  $this
    ->drupalPost(NULL, array(
    "question[{$question_node->nid}][answer][1]" => 0,
    "question[{$question_node->nid}][answer][2]" => 2,
  ), t('Next'));
}