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