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