MDL-64420 qtype: gapselect unit tests unsafe
[moodle.git] / question / behaviour / interactivecountback / tests / walkthrough_test.php
index 7d550a2..583a41b 100644 (file)
@@ -52,7 +52,7 @@ class qbehaviour_interactivecountback_walkthrough_test extends qbehaviour_walkth
 
         $choiceorder = $m->get_choice_order();
         $orderforchoice = array_combine(array_values($choiceorder), array_keys($choiceorder));
-        $choices = array(0 => get_string('choose') . '...');
+        $choices = [];
         foreach ($choiceorder as $key => $choice) {
             $choices[$key] = $m->choices[$choice];
         }
@@ -63,16 +63,17 @@ class qbehaviour_interactivecountback_walkthrough_test extends qbehaviour_walkth
         $this->assertEquals('interactivecountback',
                 $this->quba->get_question_attempt($this->slot)->get_behaviour_name());
         $this->check_current_output(
-                $this->get_contains_select_expectation('sub0', $choices, null, true),
-                $this->get_contains_select_expectation('sub1', $choices, null, true),
-                $this->get_contains_select_expectation('sub2', $choices, null, true),
-                $this->get_contains_select_expectation('sub3', $choices, null, true),
                 $this->get_contains_question_text_expectation($m),
                 $this->get_contains_submit_button_expectation(true),
                 $this->get_does_not_contain_feedback_expectation(),
                 $this->get_tries_remaining_expectation(3),
                 $this->get_does_not_contain_num_parts_correct(),
                 $this->get_no_hint_visible_expectation());
+        $this->check_output_contains_selectoptions(
+                $this->get_contains_select_expectation('sub0', $choices, null, true),
+                $this->get_contains_select_expectation('sub1', $choices, null, true),
+                $this->get_contains_select_expectation('sub2', $choices, null, true),
+                $this->get_contains_select_expectation('sub3', $choices, null, true));
 
         // Submit an answer with two right, and two wrong.
         $this->process_submission(array('sub0' => $orderforchoice[1],
@@ -83,10 +84,6 @@ class qbehaviour_interactivecountback_walkthrough_test extends qbehaviour_walkth
         $this->check_current_state(question_state::$todo);
         $this->check_current_mark(null);
         $this->check_current_output(
-                $this->get_contains_select_expectation('sub0', $choices, $orderforchoice[1], false),
-                $this->get_contains_select_expectation('sub1', $choices, $orderforchoice[1], false),
-                $this->get_contains_select_expectation('sub2', $choices, $orderforchoice[1], false),
-                $this->get_contains_select_expectation('sub3', $choices, $orderforchoice[1], false),
                 $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_try_again_button_expectation(true),
                 $this->get_does_not_contain_correctness_expectation(),
@@ -102,6 +99,11 @@ class qbehaviour_interactivecountback_walkthrough_test extends qbehaviour_walkth
                         $this->quba->get_field_prefix($this->slot) . 'sub2', '0'),
                 $this->get_contains_hidden_expectation(
                         $this->quba->get_field_prefix($this->slot) . 'sub3', $orderforchoice[1]));
+        $this->check_output_contains_selectoptions(
+                $this->get_contains_select_expectation('sub0', $choices, $orderforchoice[1], false),
+                $this->get_contains_select_expectation('sub1', $choices, $orderforchoice[1], false),
+                $this->get_contains_select_expectation('sub2', $choices, $orderforchoice[1], false),
+                $this->get_contains_select_expectation('sub3', $choices, $orderforchoice[1], false));
 
         // Check that extract responses will return the reset data.
         $prefix = $this->quba->get_field_prefix($this->slot);
@@ -116,15 +118,16 @@ class qbehaviour_interactivecountback_walkthrough_test extends qbehaviour_walkth
         $this->check_current_state(question_state::$todo);
         $this->check_current_mark(null);
         $this->check_current_output(
-                $this->get_contains_select_expectation('sub0', $choices, $orderforchoice[1], true),
-                $this->get_contains_select_expectation('sub1', $choices, null, true),
-                $this->get_contains_select_expectation('sub2', $choices, null, true),
-                $this->get_contains_select_expectation('sub3', $choices, $orderforchoice[1], true),
                 $this->get_contains_submit_button_expectation(true),
                 $this->get_does_not_contain_correctness_expectation(),
                 $this->get_does_not_contain_feedback_expectation(),
                 $this->get_tries_remaining_expectation(2),
                 $this->get_no_hint_visible_expectation());
+        $this->check_output_contains_selectoptions(
+                $this->get_contains_select_expectation('sub0', $choices, $orderforchoice[1], true),
+                $this->get_contains_select_expectation('sub1', $choices, null, true),
+                $this->get_contains_select_expectation('sub2', $choices, null, true),
+                $this->get_contains_select_expectation('sub3', $choices, $orderforchoice[1], true));
 
         // Submit the right answer.
         $this->process_submission(array('sub0' => $orderforchoice[1],
@@ -135,14 +138,15 @@ class qbehaviour_interactivecountback_walkthrough_test extends qbehaviour_walkth
         $this->check_current_state(question_state::$gradedright);
         $this->check_current_mark(10);
         $this->check_current_output(
-                $this->get_contains_select_expectation('sub0', $choices, $orderforchoice[1], false),
-                $this->get_contains_select_expectation('sub1', $choices, $orderforchoice[2], false),
-                $this->get_contains_select_expectation('sub2', $choices, $orderforchoice[2], false),
-                $this->get_contains_select_expectation('sub3', $choices, $orderforchoice[1], false),
                 $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_does_not_contain_try_again_button_expectation(),
                 $this->get_contains_correct_expectation(),
                 $this->get_contains_standard_correct_combined_feedback_expectation(),
                 new question_no_pattern_expectation('/class="control\b[^"]*\bpartiallycorrect"/'));
+        $this->check_output_contains_selectoptions(
+                $this->get_contains_select_expectation('sub0', $choices, $orderforchoice[1], false),
+                $this->get_contains_select_expectation('sub1', $choices, $orderforchoice[2], false),
+                $this->get_contains_select_expectation('sub2', $choices, $orderforchoice[2], false),
+                $this->get_contains_select_expectation('sub3', $choices, $orderforchoice[1], false));
     }
 }