You are here

public function MultichoiceTestCase::testEditQuestionResponse in Quiz 7.5

Test that the question response can be edited.

File

question_types/multichoice/multichoice.test, line 291
Test suite for choice Questions type module.

Class

MultichoiceTestCase
Test class for multichoice 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][user_answer]" => 1,
  ), t('Next'));
  $this
    ->drupalGet("node/{$quiz_node->nid}/take/1");
  $this
    ->drupalPost(NULL, array(
    "question[{$question_node->nid}][answer][user_answer]" => 2,
  ), t('Next'));
}