public function QuizTakingTest::testAnswerSkipped in Quiz 6.x
Same name and namespace in other branches
- 8.6 tests/src/Functional/QuizTakingTest.php \Drupal\Tests\quiz\Functional\QuizTakingTest::testAnswerSkipped()
- 8.5 tests/src/Functional/QuizTakingTest.php \Drupal\Tests\quiz\Functional\QuizTakingTest::testAnswerSkipped()
Test that a user can answer a skipped question.
File
- tests/
src/ Functional/ QuizTakingTest.php, line 248
Class
- QuizTakingTest
- Test quiz taking behavior.
Namespace
Drupal\Tests\quiz\FunctionalCode
public function testAnswerSkipped() {
$this
->drupalLogin($this->admin);
$quiz_node = $this
->createQuiz([
'allow_skipping' => 1,
'allow_jumping' => 1,
]);
// 2 questions.
$question1 = $this
->createQuestion([
'type' => 'truefalse',
'truefalse_correct' => 1,
]);
$this
->linkQuestionToQuiz($question1, $quiz_node);
$question2 = $this
->createQuestion([
'type' => 'truefalse',
'truefalse_correct' => 1,
]);
$this
->linkQuestionToQuiz($question2, $quiz_node);
$this
->drupalLogin($this->user);
// Leave a question blank.
$this
->drupalGet("quiz/{$quiz_node->id()}/take");
$this
->drupalGet("quiz/{$quiz_node->id()}/take/1");
$this
->drupalPostForm(NULL, [], t('Leave blank'));
// Fill out the blank question.
$this
->drupalGet("quiz/{$quiz_node->id()}/take/1");
$this
->drupalPostForm(NULL, [
"question[{$question1->id()}][answer]" => 1,
], t('Next'));
$this
->drupalPostForm(NULL, [
"question[{$question2->id()}][answer]" => 1,
], t('Finish'));
$this
->assertText("Your score: 100%");
}