You are here

public function QuizDirectionsTestCase::testCreateQuizQuestion in Quiz 8.5

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

Test adding and taking a quiz directions question.

File

question_types/quiz_directions/tests/src/Functional/QuizDirectionsTestCase.php, line 29
Unit tests for the quiz_directions Module.

Class

QuizDirectionsTestCase
Test class for quiz directions.

Namespace

Drupal\Tests\quiz_directions\Functional

Code

public function testCreateQuizQuestion($settings = []) {

  // Login as our privileged user.
  $this
    ->drupalLogin($this->admin);
  $question = QuizQuestion::create([
    'type' => $this
      ->getQuestionType(),
    'title' => 'QD 1 title',
    'body' => 'QD 1 body text.',
  ]);
  $question
    ->save();
  $quiz = $this
    ->linkQuestionToQuiz($question);
  $this
    ->drupalLogin($this->user);
  $this
    ->drupalGet("quiz/{$quiz->id()}/take");
  $this
    ->assertText('QD 1 body text.');
  return $question;
}