You are here

public function QuizTakingTest::testQuestionCount in Quiz 8.5

Same name and namespace in other branches
  1. 8.6 tests/src/Functional/QuizTakingTest.php \Drupal\Tests\quiz\Functional\QuizTakingTest::testQuestionCount()
  2. 6.x tests/src/Functional/QuizTakingTest.php \Drupal\Tests\quiz\Functional\QuizTakingTest::testQuestionCount()

Verify non gradable questions are excluded from counts.

File

tests/src/Functional/QuizTakingTest.php, line 279

Class

QuizTakingTest
Test quiz taking behavior.

Namespace

Drupal\Tests\quiz\Functional

Code

public function testQuestionCount() {
  $quiz_node = $this
    ->createQuiz(array(
    'review_options' => array(
      'question' => array(
        'score' => 'score',
      ),
    ),
  ));
  $question1 = $this
    ->createQuestion(array(
    'type' => 'truefalse',
    'truefalse_correct' => 1,
  ));
  $this
    ->linkQuestionToQuiz($question1, $quiz_node);
  $question2 = $this
    ->createQuestion(array(
    'type' => 'directions',
  ));
  $this
    ->linkQuestionToQuiz($question2, $quiz_node);
  $question3 = $this
    ->createQuestion(array(
    'type' => 'truefalse',
    'truefalse_correct' => 1,
  ));
  $this
    ->linkQuestionToQuiz($question3, $quiz_node);
  $question4 = $this
    ->createQuestion(array(
    'type' => 'truefalse',
    'truefalse_correct' => 1,
  ));
  $this
    ->linkQuestionToQuiz($question4, $quiz_node);
  $question5 = $this
    ->createQuestion(array(
    'type' => 'truefalse',
    'truefalse_correct' => 1,
  ));
  $this
    ->linkQuestionToQuiz($question5, $quiz_node);
  $this
    ->drupalLogin($this->user);
  $this
    ->drupalGet("quiz/{$quiz_node->id()}");

  // @todo check the pager, this isn't reliable
  $this
    ->assertText("4");
}