public function QuizCreationTest::testCloneQuiz in Quiz 8.6
Same name and namespace in other branches
- 8.5 tests/src/Functional/QuizCreationTest.php \Drupal\Tests\quiz\Functional\QuizCreationTest::testCloneQuiz()
- 6.x tests/src/Functional/QuizCreationTest.php \Drupal\Tests\quiz\Functional\QuizCreationTest::testCloneQuiz()
Test cloning quizzes with questions.
File
- tests/
src/ Functional/ QuizCreationTest.php, line 102
Class
- QuizCreationTest
- Test aspects of quiz creation including global and user defaults.
Namespace
Drupal\Tests\quiz\FunctionalCode
public function testCloneQuiz() {
$this
->drupalLogin($this->admin);
$question = $this
->createQuestion(array(
'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');
}