From f061709e62c68d4926fec9c3f2be63b765961bcd Mon Sep 17 00:00:00 2001 From: Shamim Rezaie Date: Mon, 25 Sep 2017 12:54:05 +0100 Subject: [PATCH] MDL-57228 quiz editing: unit test for the move case --- mod/quiz/tests/structure_test.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/mod/quiz/tests/structure_test.php b/mod/quiz/tests/structure_test.php index add60070082..96433d91930 100644 --- a/mod/quiz/tests/structure_test.php +++ b/mod/quiz/tests/structure_test.php @@ -648,6 +648,34 @@ class mod_quiz_structure_testcase extends advanced_testcase { ), $structure); } + public function test_move_slot_does_not_violate_heading_unique_key() { + $quizobj = $this->create_test_quiz(array( + 'Heading 1', + array('TF1', 1, 'truefalse'), + 'Heading 2', + array('TF2', 2, 'truefalse'), + 'Heading 3', + array('TF3', 3, 'truefalse'), + array('TF4', 3, 'truefalse'), + )); + $structure = \mod_quiz\structure::create_for_quiz($quizobj); + + $idtomove = $structure->get_question_in_slot(4)->slotid; + $idmoveafter = $structure->get_question_in_slot(1)->slotid; + $structure->move_slot($idtomove, $idmoveafter, 1); + + $structure = \mod_quiz\structure::create_for_quiz($quizobj); + $this->assert_quiz_layout(array( + 'Heading 1', + array('TF1', 1, 'truefalse'), + array('TF4', 1, 'truefalse'), + 'Heading 2', + array('TF2', 2, 'truefalse'), + 'Heading 3', + array('TF3', 3, 'truefalse'), + ), $structure); + } + public function test_quiz_remove_slot() { $quizobj = $this->create_test_quiz(array( array('TF1', 1, 'truefalse'),