You are here

QuizDeleteTest.php in Quiz 6.x

File

tests/src/Functional/QuizDeleteTest.php
View source
<?php

namespace Drupal\Tests\quiz\Functional;


/**
 * Test aspects of quiz deletion.
 *
 * @group Quiz
 */
class QuizDeletionTest extends QuizTestBase {
  protected static $modules = [
    'quiz_truefalse',
  ];

  /**
   * Test basic quiz creation.
   */
  public function testQuizDeletion() {
    $this
      ->drupalLogin($this->user);
    $quiz_node = $this
      ->createQuiz();

    // 2 questions.
    $question1 = $this
      ->createQuestion([
      'type' => 'truefalse',
      'truefalse_correct' => 1,
    ]);
    $this
      ->linkQuestionToQuiz($question1, $quiz_node);
    $question2 = $this
      ->createQuestion([
      'type' => 'truefalse',
      'truefalse_correct' => 1,
    ]);
    $this
      ->linkQuestionToQuiz($question2, $quiz_node);
    $this
      ->drupalLogin($this->user);
    $this
      ->drupalGet("quiz/{$quiz_node->id()}/take");
    $this
      ->drupalPostForm(NULL, [
      "question[{$question1->id()}][answer]" => 1,
    ], t('Next'));
    $this
      ->drupalPostForm(NULL, [
      "question[{$question2->id()}][answer]" => 1,
    ], t('Finish'));

    // Delete user
    $this->user
      ->delete();

    // Delete the quiz
    $quiz_node
      ->delete();
  }

}

Classes

Namesort descending Description
QuizDeletionTest Test aspects of quiz deletion.