public function QuizFeedbackTest::testQuestionBodyFeedback in Quiz 6.x
Same name and namespace in other branches
- 8.6 tests/src/Functional/QuizFeedbackTest.php \Drupal\Tests\quiz\Functional\QuizFeedbackTest::testQuestionBodyFeedback()
- 8.5 tests/src/Functional/QuizFeedbackTest.php \Drupal\Tests\quiz\Functional\QuizFeedbackTest::testQuestionBodyFeedback()
Test Quiz question body feedback.
File
- tests/
src/ Functional/ QuizFeedbackTest.php, line 198
Class
- QuizFeedbackTest
- Test quiz feedback.
Namespace
Drupal\Tests\quiz\FunctionalCode
public function testQuestionBodyFeedback() {
$this
->drupalLogin($this->admin);
// Asolutely no feedback.
$quiz = $this
->createQuiz([
'review_options' => [],
]);
// Set up a Quiz with one question that has a body and a summary.
$question1 = $this
->createQuestion([
'type' => 'truefalse',
'body' => 'TF 1 body text',
'truefalse_correct' => 1,
]);
$this
->linkQuestionToQuiz($question1, $quiz);
// Test no feedback.
$this
->drupalLogin($this->user);
$this
->drupalGet("quiz/{$quiz->id()}/take");
$this
->drupalPostForm(NULL, [
"question[{$question1->id()}][answer]" => 1,
], t('Finish'));
$this
->assertNoText('TF 1 body text');
// Test full feedback.
$quiz->review_options = [
'end' => [
'quiz_question_view_full' => 'quiz_question_view_full',
],
];
$quiz
->save();
$this
->drupalLogin($this->user);
$this
->drupalGet("quiz/{$quiz->id()}/take");
$this
->drupalPostForm(NULL, [
"question[{$question1->id()}][answer]" => 1,
], t('Finish'));
$this
->assertText('TF 1 body text');
}