QuizDeleteTest.php in Quiz 6.x
File
tests/src/Functional/QuizDeleteTest.php
View source
<?php
namespace Drupal\Tests\quiz\Functional;
class QuizDeletionTest extends QuizTestBase {
protected static $modules = [
'quiz_truefalse',
];
public function testQuizDeletion() {
$this
->drupalLogin($this->user);
$quiz_node = $this
->createQuiz();
$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'));
$this->user
->delete();
$quiz_node
->delete();
}
}