You are here

function QuizResultTestCase::testQuizResultAccess in Quiz 7.6

Same name and namespace in other branches
  1. 7.5 tests/QuizResultTestCase.test \QuizResultTestCase::testQuizResultAccess()

Test access to results.

File

tests/QuizResultTestCase.test, line 188

Class

QuizResultTestCase

Code

function testQuizResultAccess() {
  $this
    ->drupalLogin($this->admin);
  $question_node1 = $this
    ->drupalCreateNode(array(
    'type' => 'truefalse',
    'correct_answer' => 1,
  ));
  $quiz_node = $this
    ->linkQuestionToQuiz($question_node1);

  // Submit an answer.
  $this
    ->drupalLogin($this->user);
  $this
    ->drupalGet("node/{$quiz_node->nid}/take");
  $this
    ->drupalPost(NULL, array(
    "question[{$question_node1->nid}][answer]" => 1,
  ), t('Finish'));
  $resultsUrl = $this
    ->getUrl();
  $this
    ->drupalGet($resultsUrl);
  $this
    ->assertResponse(200, t('User can view own result'));
  $this
    ->drupalLogout();
  $this
    ->drupalGet($resultsUrl);
  $this
    ->assertNoResponse(200, t('Anonymous user cannot view result'));
}