You are here

public function QuizTrueFalseTestCase::testQuestionFeedback in Quiz 8.5

Same name and namespace in other branches
  1. 8.6 question_types/quiz_truefalse/tests/src/Functional/QuizTrueFalseTestCase.php \Drupal\Tests\quiz_truefalse\Functional\QuizTrueFalseTestCase::testQuestionFeedback()
  2. 6.x question_types/quiz_truefalse/tests/src/Functional/QuizTrueFalseTestCase.php \Drupal\Tests\quiz_truefalse\Functional\QuizTrueFalseTestCase::testQuestionFeedback()

Test incorrect question with all feedbacks on.

File

question_types/quiz_truefalse/tests/src/Functional/QuizTrueFalseTestCase.php, line 82

Class

QuizTrueFalseTestCase
Test class for true false questions.

Namespace

Drupal\Tests\quiz_truefalse\Functional

Code

public function testQuestionFeedback() {

  // Login as our privileged user.
  $this
    ->drupalLogin($this->admin);

  // Create the quiz and question.
  $question = $this
    ->testCreateQuizQuestion();

  // Link the question.
  $quiz = $this
    ->linkQuestionToQuiz($question);

  // Login as non-admin.
  $this
    ->drupalLogin($this->user);

  // Take the quiz.
  $this
    ->drupalGet("quiz/{$quiz->id()}/take");
  $this
    ->drupalPostForm(NULL, array(
    "question[{$question->id()}][answer]" => 1,
  ), t('Finish'));
  $this
    ->assertRaw('quiz-score-icon correct');
  $this
    ->assertRaw('quiz-score-icon should');

  // Take the quiz.
  $this
    ->drupalGet("quiz/{$quiz->id()}/take");
  $this
    ->drupalPostForm(NULL, array(
    "question[{$question->id()}][answer]" => 0,
  ), t('Finish'));
  $this
    ->assertRaw('quiz-score-icon incorrect');
  $this
    ->assertRaw('quiz-score-icon should');
}