public function QuizTakingTest::testMarkDoubtful in Quiz 6.x
Same name and namespace in other branches
- 8.6 tests/src/Functional/QuizTakingTest.php \Drupal\Tests\quiz\Functional\QuizTakingTest::testMarkDoubtful()
- 8.5 tests/src/Functional/QuizTakingTest.php \Drupal\Tests\quiz\Functional\QuizTakingTest::testMarkDoubtful()
Test the mark doubtful functionality.
File
- tests/
src/ Functional/ QuizTakingTest.php, line 368
Class
- QuizTakingTest
- Test quiz taking behavior.
Namespace
Drupal\Tests\quiz\FunctionalCode
public function testMarkDoubtful() {
$this
->drupalLogin($this->admin);
$quiz_node = $this
->createQuiz([
'allow_skipping' => 1,
'allow_jumping' => 1,
'mark_doubtful' => 1,
]);
// 2 questions.
$question1 = $this
->createQuestion([
'type' => 'truefalse',
'truefalse_correct' => 1,
]);
$this
->linkQuestionToQuiz($question1, $quiz_node);
$question2 = $this
->createQuestion([
'type' => 'directions',
]);
$this
->linkQuestionToQuiz($question2, $quiz_node);
// Take the quiz.
$this
->drupalLogin($this->user);
$this
->drupalGet("quiz/{$quiz_node->id()}/take");
// Ensure it is on truefalse.
$this
->drupalGet("quiz/{$quiz_node->id()}/take/1");
$this
->assertField("edit-question-{$question1->id()}-is-doubtful");
$this
->drupalPostForm(NULL, [
"question[{$question1->id()}][answer]" => 1,
"question[{$question1->id()}][is_doubtful]" => 1,
], t('Next'));
// Go back and verify it was saved.
$this
->drupalGet("quiz/{$quiz_node->id()}/take/1");
$this
->assertFieldChecked("edit-question-{$question1->id()}-is-doubtful");
// Ensure it is not on quiz directions.
$this
->drupalGet("quiz/{$quiz_node->id()}/take/2");
$this
->assertNoField("edit-question-{$question2->id()}-is-doubtful");
}