public function QuizDeletionTest::testQuizDeletion in Quiz 6.x
Test basic quiz creation.
File
- tests/
src/ Functional/ QuizDeleteTest.php, line 17
Class
- QuizDeletionTest
- Test aspects of quiz deletion.
Namespace
Drupal\Tests\quiz\FunctionalCode
public function testQuizDeletion() {
$this
->drupalLogin($this->user);
$quiz_node = $this
->createQuiz();
// 2 questions.
$question1 = $this
->createQuestion([
'type' => 'truefalse',
'truefalse_correct' => 1,
]);
$this
->linkQuestionToQuiz($question1, $quiz_node);
$question2 = $this
->createQuestion([
'type' => 'truefalse',
'truefalse_correct' => 1,
]);
$this
->linkQuestionToQuiz($question2, $quiz_node);
$this
->drupalLogin($this->user);
$this
->drupalGet("quiz/{$quiz_node->id()}/take");
$this
->drupalPostForm(NULL, [
"question[{$question1->id()}][answer]" => 1,
], t('Next'));
$this
->drupalPostForm(NULL, [
"question[{$question2->id()}][answer]" => 1,
], t('Finish'));
// Delete user
$this->user
->delete();
// Delete the quiz
$quiz_node
->delete();
}