public function QuizResultTest::testQuizResultAccess in Quiz 8.6
Same name and namespace in other branches
- 8.5 tests/src/Functional/QuizResultTest.php \Drupal\Tests\quiz\Functional\QuizResultTest::testQuizResultAccess()
- 6.x tests/src/Functional/QuizResultTest.php \Drupal\Tests\quiz\Functional\QuizResultTest::testQuizResultAccess()
Test access to results.
File
- tests/
src/ Functional/ QuizResultTest.php, line 193
Class
- QuizResultTest
- Test quiz results behavior.
Namespace
Drupal\Tests\quiz\FunctionalCode
public function testQuizResultAccess() {
$this
->drupalLogin($this->admin);
$question1 = $this
->createQuestion(array(
'type' => 'truefalse',
'truefalse_correct' => 1,
));
$quiz_node = $this
->linkQuestionToQuiz($question1);
// Submit an answer.
$this
->drupalLogin($this->user);
$this
->drupalGet("quiz/{$quiz_node->id()}/take");
$this
->drupalPostForm(NULL, array(
"question[{$question1->id()}][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
->assertSession()
->statusCodeEquals(403);
}