public function QuizCreationTest::testCloneQuiz in Quiz 6.x
Same name and namespace in other branches
- 8.6 tests/src/Functional/QuizCreationTest.php \Drupal\Tests\quiz\Functional\QuizCreationTest::testCloneQuiz()
- 8.5 tests/src/Functional/QuizCreationTest.php \Drupal\Tests\quiz\Functional\QuizCreationTest::testCloneQuiz()
Test cloning quizzes with questions.
File
- tests/
src/ Functional/ QuizCreationTest.php, line 42
Class
- QuizCreationTest
- Test aspects of quiz creation.
Namespace
Drupal\Tests\quiz\FunctionalCode
public function testCloneQuiz() {
$this
->drupalLogin($this->admin);
$question = $this
->createQuestion([
'title' => 'TF 1',
'body' => 'TF 1',
'type' => 'truefalse',
'truefalse_correct' => 1,
]);
$quiz = $this
->linkQuestionToQuiz($question);
$quiz
->save();
$new_quiz = $quiz
->createDuplicate();
$new_quiz
->save();
$this
->assertNotEquals($new_quiz
->id(), $quiz
->id());
$this
->drupalLogin($this->user);
$this
->drupalGet("quiz/{$quiz->id()}/take");
$this
->assertText('TF 1');
$this
->drupalGet("quiz/{$new_quiz->id()}/take");
$this
->assertText('TF 1');
}