You are here

public function QuizFeedbackTest::testNoFeedback in Quiz 6.x

Same name and namespace in other branches
  1. 8.6 tests/src/Functional/QuizFeedbackTest.php \Drupal\Tests\quiz\Functional\QuizFeedbackTest::testNoFeedback()
  2. 8.5 tests/src/Functional/QuizFeedbackTest.php \Drupal\Tests\quiz\Functional\QuizFeedbackTest::testNoFeedback()

Test no feedback.

File

tests/src/Functional/QuizFeedbackTest.php, line 159

Class

QuizFeedbackTest
Test quiz feedback.

Namespace

Drupal\Tests\quiz\Functional

Code

public function testNoFeedback() {
  $this
    ->drupalLogin($this->admin);

  // Turn off question feedback.
  $quiz = $this
    ->createQuiz([
    'review_options' => [],
  ]);

  // Add 2 questions with general question feedback.
  $question1 = $this
    ->createQuestion([
    'type' => 'truefalse',
    'truefalse_correct' => 1,
    'feedback' => 'Feedback for TF test.',
  ]);
  $this
    ->linkQuestionToQuiz($question1, $quiz);
  $question2 = $this
    ->createQuestion([
    'type' => 'truefalse',
    'truefalse_correct' => 1,
    'feedback' => 'Feedback for TF test.',
  ]);
  $this
    ->linkQuestionToQuiz($question2, $quiz);

  // Test.
  $this
    ->drupalLogin($this->user);
  $this
    ->drupalGet("quiz/{$quiz->id()}/take");
  $this
    ->drupalPostForm(NULL, [
    "question[{$question1->id()}][answer]" => 1,
  ], t('Next'));
  $this
    ->drupalPostForm(NULL, [
    "question[{$question2->id()}][answer]" => 1,
  ], t('Finish'));
  $this
    ->assertText('You have finished this Quiz');
}