public function ScaleTestCase::testTakeQuestion in Quiz 7.5
Same name and namespace in other branches
- 8.6 question_types/quiz_scale/quiz_scale.test \ScaleTestCase::testTakeQuestion()
- 8.5 question_types/quiz_scale/quiz_scale.test \ScaleTestCase::testTakeQuestion()
- 7.6 question_types/scale/scale.test \ScaleTestCase::testTakeQuestion()
File
- question_types/
scale/ scale.test, line 60 - Test suite for scale question type module.
Class
- ScaleTestCase
- Test class for scale questions.
Code
public function testTakeQuestion() {
$question_node = $this
->testCreateQuizQuestion();
// Link the question.
$quiz_node = $this
->linkQuestionToQuiz($question_node);
// Test that question appears in lists.
$this
->drupalGet("node/{$quiz_node->nid}/quiz/questions");
$this
->assertText('Scale 1 title');
// Login as non-admin.
$this
->drupalLogin($this->user);
// Take the quiz.
$this
->drupalGet("node/{$quiz_node->nid}/take");
$this
->assertNoText('Scale 1 title');
$this
->assertText('Scale 1 body text');
$this
->assertText('This is alternative 1');
$this
->assertText('This is alternative 2');
// Test validation.
$this
->drupalPost(NULL, array(), t('Finish'));
$this
->assertText('You must provide an answer.');
// Test any question.
$this
->drupalGet("node/{$quiz_node->nid}/take");
$this
->drupalPost(NULL, array(
// Alternative #2 is actually 24 (because of the presets).
"question[{$question_node->nid}][answer]" => 24,
), t('Finish'));
$this
->assertText('You got 1 of 1 possible points.');
}