public function QuizTakingTest::testAnswerOnOldQuizRevisioning in Quiz 8.6
Same name and namespace in other branches
- 8.5 tests/src/Functional/QuizTakingTest.php \Drupal\Tests\quiz\Functional\QuizTakingTest::testAnswerOnOldQuizRevisioning()
- 6.x tests/src/Functional/QuizTakingTest.php \Drupal\Tests\quiz\Functional\QuizTakingTest::testAnswerOnOldQuizRevisioning()
Make sure a user can answer or skip an old question's revision.
File
- tests/
src/ Functional/ QuizTakingTest.php, line 240
Class
- QuizTakingTest
- Test quiz taking behavior.
Namespace
Drupal\Tests\quiz\FunctionalCode
public function testAnswerOnOldQuizRevisioning() {
$this
->drupalLogin($this->admin);
$question1 = $this
->createQuestion(array(
'title' => 'Q 1',
'body' => 'Q 1',
'type' => 'truefalse',
'truefalse_correct' => 1,
));
$quiz_node = $this
->linkQuestionToQuiz($question1);
$question2 = $this
->createQuestion(array(
'title' => 'Q 2',
'body' => 'Q 2',
'type' => 'truefalse',
'truefalse_correct' => 1,
));
$this
->linkQuestionToQuiz($question2, $quiz_node);
$question1->revision = TRUE;
$question1
->save();
$this
->drupalLogin($this->user);
$this
->drupalGet("quiz/{$quiz_node->id()}/take");
// Leave a question blank.
$this
->drupalGet("quiz/{$quiz_node->id()}/take/1");
$this
->drupalPostForm(NULL, array(), t('Leave blank'));
// Submit the question.
$this
->drupalGet("quiz/{$quiz_node->id()}/take/1");
$this
->drupalPostForm(NULL, array(
"question[{$question1->id()}][answer]" => 1,
), t('Next'));
}