public function QuizCreationTest::testQuestionRevisionActions in Quiz 8.6
Same name and namespace in other branches
- 8.5 tests/src/Functional/QuizCreationTest.php \Drupal\Tests\quiz\Functional\QuizCreationTest::testQuestionRevisionActions()
Test quiz revisioning.
File
- tests/
src/ Functional/ QuizCreationTest.php, line 127
Class
- QuizCreationTest
- Test aspects of quiz creation including global and user defaults.
Namespace
Drupal\Tests\quiz\FunctionalCode
public function testQuestionRevisionActions() {
$this
->drupalLogin($this->admin);
$question_node = $this
->createQuestion(array(
'title' => 'Revision 1',
'body' => 'Revision 1',
'type' => 'truefalse',
'truefalse_correct' => 1,
));
$quiz_node = $this
->linkQuestionToQuiz($question_node);
// Check for first revision.
$this
->drupalGet("quiz/{$quiz_node->id()}/take");
$this
->assertText("Revision 1");
// Save the question.
$this
->drupalGet("quiz/{$question_node->nid}/edit");
$this
->drupalPostForm(NULL, array(), t('Save'));
$this
->assertText(t('Revision actions'));
// Basic quiz admins won't be able to select this one.
$this
->assertNoText(t('Update (no revision)'));
$this
->assertText(t('Create new revision'));
$this
->assertText(t('Do nothing'));
$this
->assertText(t('Leave published'));
// Check that we have the opportunity to revise the quiz.
$this
->drupalGet("quiz/{$quiz_node->id()}/questions");
$this
->assertField("edit-revision-{$question_node->nid}-{$question_node->vid}");
$this
->drupalGet("quiz/{$question_node->nid}/question-revision-actions");
$this
->drupalPostForm(NULL, array(
"quizzes[{$quiz_node->nid}][revise]" => 'revise',
), t('Submit'));
$this
->assertText('succesfully revised');
$this
->drupalGet("quiz/{$question_node->nid}/question-revision-actions");
$this
->drupalPostForm(NULL, array(
"quizzes[{$quiz_node->nid}][revise]" => 'nothing',
), t('Submit'));
$this
->assertText('Quiz not updated, please use the Quiz question listing to if you decide to update the quiz manually.');
// Check that we no longer have the opportunity to revise the quiz.
$this
->drupalGet("quiz/{$quiz_node->id()}/questions");
$this
->assertNoField("edit-revision-{$question_node->nid}-{$question_node->vid}");
// Check that a better admin can manually update the quiz (no revisioning).
$better_admin = $this
->drupalCreateUser(array(
'edit any truefalse content',
'update any quiz quiz',
'manual quiz revisioning',
));
$this
->drupalLogin($better_admin);
$this
->drupalGet("quiz/{$question_node->nid}/question-revision-actions");
$this
->drupalPostForm(NULL, array(
"quizzes[{$quiz_node->nid}][revise]" => 'update',
), t('Submit'));
$this
->assertText('succesfully updated');
}