public function QuizTakingTest::testViewQuestionsOutsideQuiz in Quiz 6.x
Same name and namespace in other branches
- 8.6 tests/src/Functional/QuizTakingTest.php \Drupal\Tests\quiz\Functional\QuizTakingTest::testViewQuestionsOutsideQuiz()
- 8.5 tests/src/Functional/QuizTakingTest.php \Drupal\Tests\quiz\Functional\QuizTakingTest::testViewQuestionsOutsideQuiz()
Make sure questions cannot be viewed outside of quizzes.
File
- tests/
src/ Functional/ QuizTakingTest.php, line 77
Class
- QuizTakingTest
- Test quiz taking behavior.
Namespace
Drupal\Tests\quiz\FunctionalCode
public function testViewQuestionsOutsideQuiz() {
$this
->drupalLogin($this->admin);
$quiz_node = $this
->createQuiz();
$question1 = $this
->createQuestion([
'type' => 'truefalse',
'truefalse_correct' => 1,
]);
$this
->linkQuestionToQuiz($question1, $quiz_node);
$this
->drupalLogin($this->user);
$this
->drupalGet("quiz-question/{$question1->id()}");
$this
->assertResponse(403);
$user_with_privs = $this
->drupalCreateUser([
'view quiz_question',
'access quiz',
]);
$this
->drupalLogin($user_with_privs);
$this
->drupalGet("quiz-question/{$question1->id()}");
$this
->assertResponse(200);
}