QuizCreationTest.php in Quiz 6.x
File
tests/src/Functional/QuizCreationTest.php
View source
<?php
namespace Drupal\Tests\quiz\Functional;
class QuizCreationTest extends QuizTestBase {
protected static $modules = [
'quiz_truefalse',
];
public function testQuizCreation() {
$this
->drupalLogin($this->admin);
$this
->drupalGet("quiz/add/quiz");
$this
->assertFieldChecked('edit-allow-resume-value');
$this
->assertFieldChecked('edit-allow-skipping-value');
$this
->assertNoFieldChecked('edit-allow-jumping-value');
$this
->assertFieldChecked('edit-allow-change-value');
$this
->assertFieldChecked('edit-backwards-navigation-value');
$this
->assertNoFieldChecked('edit-repeat-until-correct-value');
$this
->assertNoFieldChecked('edit-mark-doubtful-value');
$this
->assertFieldChecked('edit-show-passed-value');
$this
->assertFieldChecked('edit-status-value');
$this
->drupalPostForm(NULL, [
'title[0][value]' => 'Test quiz creation',
'body[0][value]' => 'Test quiz description',
], t('Save'));
$this
->assertText('Manage questions');
}
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');
}
}