You are here

public function QuizRevisioningTest::testQuizNoRevisioning in Quiz 8.6

Same name and namespace in other branches
  1. 8.5 tests/src/Functional/QuizRevisioningTest.php \Drupal\Tests\quiz\Functional\QuizRevisioningTest::testQuizNoRevisioning()
  2. 6.x tests/src/Functional/QuizRevisioningTest.php \Drupal\Tests\quiz\Functional\QuizRevisioningTest::testQuizNoRevisioning()

Test quiz with revisioning off.

File

tests/src/Functional/QuizRevisioningTest.php, line 126

Class

QuizRevisioningTest
Test quiz revisioning.

Namespace

Drupal\Tests\quiz\Functional

Code

public function testQuizNoRevisioning() {
  $this
    ->drupalLogin($this->admin);
  $question_node = $this
    ->createQuestion(array(
    'title' => 'Revision 1',
    'body' => 'Revision 1',
    'type' => 'truefalse',
    'truefalse_correct' => 1,
    'feedback' => 'Question feedback for Revision 1',
  ));
  $quiz_node = $this
    ->linkQuestionToQuiz($question_node);
  $this
    ->drupalGet("quiz/{$quiz_node->id()}/take");
  $this
    ->assertText("Revision 1");

  // Finish the attempt.
  $this
    ->drupalPostForm(NULL, array(
    "question[{$question_node->id()}][answer]" => 1,
  ), t('Finish'));

  // Check blocked access to update quiz and question.
  $this
    ->drupalGet("quiz/{$quiz_node->id()}/edit");
  $this
    ->assertText('You must delete all attempts on this quiz before editing.');
  $this
    ->assertSession()
    ->elementAttributeExists('css', '#edit-submit', 'disabled');
  $this
    ->drupalGet("quiz-question/{$question_node->id()}/edit");
  $this
    ->assertText('You must delete all attempts on this question before editing.');
  $this
    ->assertSession()
    ->elementAttributeExists('css', '#edit-submit', 'disabled');

  // Check admin override.
  $mega_admin = $this
    ->createUser([
    'administer quiz',
    'administer quiz_question',
    'override quiz revisioning',
  ]);
  $this
    ->drupalLogin($mega_admin);
  $this
    ->drupalGet("quiz/{$quiz_node->id()}/edit");
  $this
    ->assertText('You should delete all attempts on this quiz before editing.');
  $this
    ->drupalPostForm(NULL, array(), t('Save'));
  $this
    ->drupalGet("quiz-question/{$question_node->id()}/edit");
  $this
    ->assertText('You should delete all attempts on this question before editing.');
  $this
    ->drupalPostForm(NULL, array(), t('Save'));
}