public function MatchingTestCase::testEditQuestionResponse in Quiz 8.5
Same name and namespace in other branches
- 8.6 question_types/quiz_matching/tests/src/Functional/MatchingTestCase.php \Drupal\Tests\quiz_matching\Functional\MatchingTestCase::testEditQuestionResponse()
- 6.x question_types/quiz_matching/tests/src/Functional/MatchingTestCase.php \Drupal\Tests\quiz_matching\Functional\MatchingTestCase::testEditQuestionResponse()
Test that the question response is prefilled and can be edited.
File
- question_types/
quiz_matching/ tests/ src/ Functional/ MatchingTestCase.php, line 144
Class
- MatchingTestCase
- Test class for matching questions.
Namespace
Drupal\Tests\quiz_matching\FunctionalCode
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->id()}/take");
// Test editing a question.
$this
->drupalGet("quiz/{$quiz_node->id()}/take");
$this
->drupalGet("quiz/{$quiz_node->id()}/take/1");
$this
->drupalPostForm(NULL, array(
"question[{$question_node->id()}][answer][user_answer][1]" => 1,
), t('Next'));
$this
->drupalGet("quiz/{$quiz_node->id()}/take/1");
$this
->drupalPostForm(NULL, array(
"question[{$question_node->id()}][answer][user_answer][1]" => 0,
"question[{$question_node->id()}][answer][user_answer][2]" => 2,
), t('Next'));
}