public function QuizFeedbackTestCase::testQuestionBodyFeedback in Quiz 7.5
Same name and namespace in other branches
- 7.6 tests/QuizFeedbackTestCase.test \QuizFeedbackTestCase::testQuestionBodyFeedback()
Test Quiz question body feedback.
File
- tests/
QuizFeedbackTestCase.test, line 191 - Unit tests for the quiz question Module.
Class
- QuizFeedbackTestCase
- Base test class for Quiz questions.
Code
public function testQuestionBodyFeedback() {
$this
->drupalLogin($this->admin);
// Asolutely no feedback.
$quiz_node = $this
->drupalCreateQuiz(array(
'review_options' => array(),
));
// Set up a Quiz with one question that has a body and a summary.
$question_node1 = $this
->drupalCreateNode(array(
'type' => 'truefalse',
'body' => array(
LANGUAGE_NONE => array(
array(
'value' => 'TF 1 body text',
'summary' => 'TF 1 summary text',
),
),
),
'correct_answer' => 1,
));
$this
->linkQuestionToQuiz($question_node1, $quiz_node);
// Test no feedback.
$this
->drupalLogin($this->user);
$this
->drupalGet("node/{$quiz_node->nid}/take");
$this
->drupalPost(NULL, array(
"question[{$question_node1->nid}][answer]" => 1,
), t('Finish'));
$this
->assertNoText('TF 1 body text');
$this
->assertNoText('TF 1 summary text');
// Test full feedback.
$quiz_node->review_options = array(
'end' => drupal_map_assoc(array(
'quiz_question_view_full',
)),
);
node_save($quiz_node);
$this
->drupalLogin($this->user);
$this
->drupalGet("node/{$quiz_node->nid}/take");
$this
->drupalPost(NULL, array(
"question[{$question_node1->nid}][answer]" => 1,
), t('Finish'));
$this
->assertText('TF 1 body text');
$this
->assertNoText('TF 1 summary text');
// Test teaser feedback.
$quiz_node->review_options = array(
'end' => drupal_map_assoc(array(
'quiz_question_view_teaser',
)),
);
node_save($quiz_node);
$this
->drupalLogin($this->user);
$this
->drupalGet("node/{$quiz_node->nid}/take");
$this
->drupalPost(NULL, array(
"question[{$question_node1->nid}][answer]" => 1,
), t('Finish'));
$this
->assertNoText('TF 1 body text');
$this
->assertText('TF 1 summary text');
}