public function QuizTakingTest::testQuizMaxAttemptsMessage in Quiz 6.x
Test the max attempt message configuration.
File
- tests/
src/ Functional/ QuizTakingTest.php, line 170
Class
- QuizTakingTest
- Test quiz taking behavior.
Namespace
Drupal\Tests\quiz\FunctionalCode
public function testQuizMaxAttemptsMessage() {
$quiz_node = $this
->createQuiz([
'takes' => 2,
]);
$question1 = $this
->createQuestion([
'type' => 'truefalse',
'truefalse_correct' => 1,
]);
$this
->linkQuestionToQuiz($question1, $quiz_node);
$this
->drupalLogin($this->user);
$this
->drupalGet("quiz/{$quiz_node->id()}/take");
$this
->drupalGet("quiz/{$quiz_node->id()}/take/1");
$this
->drupalPostForm(NULL, [
"question[{$question1->id()}][answer]" => 0,
], t('Finish'));
$this
->drupalLogin($this->user);
$this
->drupalGet("quiz/{$quiz_node->id()}");
$this
->assertText('You can only take this Quiz 2 times. You have taken it 1 time.');
$quiz_node
->set('show_attempt_stats', 0)
->save();
$this
->drupalGet("quiz/{$quiz_node->id()}");
$this
->assertNoText('You can only take this Quiz 2 times. You have taken it 1 time.');
}