public function QuizResultTestCase::testQuizResultAccess in Quiz 7.5
Same name and namespace in other branches
- 7.6 tests/QuizResultTestCase.test \QuizResultTestCase::testQuizResultAccess()
Test access to results.
File
- tests/
QuizResultTestCase.test, line 195
Class
Code
public 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'));
}