You are here

public function QuizResultTest::testBrokenResults in Quiz 6.x

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

Test that deleting a question from a Quiz doesn't result in a fatal error.

File

tests/src/Functional/QuizResultTest.php, line 280

Class

QuizResultTest
Test quiz results behavior.

Namespace

Drupal\Tests\quiz\Functional

Code

public function testBrokenResults() {
  $this
    ->drupalLogin($this->admin);
  $question1 = $this
    ->createQuestion([
    'type' => 'truefalse',
    'truefalse_correct' => 1,
  ]);
  $quiz_node = $this
    ->linkQuestionToQuiz($question1);

  // Submit an answer.
  $this
    ->drupalLogin($this->user);
  $this
    ->drupalGet("quiz/{$quiz_node->id()}/take");
  $this
    ->drupalPostForm(NULL, [
    "question[{$question1->id()}][answer]" => 1,
  ], t('Finish'));

  // Delete the question.
  $question1
    ->delete();

  // And there should not be a fatal error.
  $this
    ->drupalGet("quiz/{$quiz_node->id()}/result/1");
  $this
    ->assertResponse(200, 'Saw the results page.');
}