You are here

public function ScaleTestCase::testEditQuestionResponse in Quiz 8.5

Same name and namespace in other branches
  1. 8.6 question_types/quiz_scale/quiz_scale.test \ScaleTestCase::testEditQuestionResponse()
  2. 7.5 question_types/scale/scale.test \ScaleTestCase::testEditQuestionResponse()

Test that the question response can be edited.

File

question_types/quiz_scale/quiz_scale.test, line 96
Test suite for scale question type module.

Class

ScaleTestCase
Test class for scale 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("quiz/{$quiz_node->nid}/take");

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