You are here

public function ShortAnswerTestCase::testGradeAnswerSensitive in Quiz 8.5

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

Test case sensitive graded questions.

File

question_types/quiz_short_answer/tests/src/Functional/ShortAnswerTestCase.php, line 78
Unit tests for the short_answer Module.

Class

ShortAnswerTestCase
Test class for short answer.

Namespace

Drupal\Tests\quiz_short_answer\Functional

Code

public function testGradeAnswerSensitive() {

  // Login as our privileged user.
  $this
    ->drupalLogin($this->admin);
  $quiz = $this
    ->createQuiz(array(
    'review_options' => array(
      'end' => array(
        'score' => 'score',
      ),
    ),
  ));
  $question = QuizQuestion::create(array(
    'type' => 'short_answer',
    'short_answer_evaluation' => ShortAnswerQuestion::ANSWER_MATCH,
    'short_answer_correct' => 'the Zero One Infinity rule',
  ));
  $question
    ->save();
  $this
    ->linkQuestionToQuiz($question, $quiz);

  // Test incorrect.
  $this
    ->drupalGet("quiz/{$quiz->id()}/take");
  $this
    ->drupalPostForm(NULL, array(
    "question[{$question->id()}][answer]" => 'the zero one Infinity rule',
  ), t('Finish'));
  $this
    ->assertText('Your score: 0%');

  // Test correct.
  $this
    ->drupalGet("quiz/{$quiz->id()}/take");
  $this
    ->drupalPostForm(NULL, array(
    "question[{$question->id()}][answer]" => 'the Zero One Infinity rule',
  ), t('Finish'));
  $this
    ->assertText('Your score: 100%');
}