MDL-64420 qtype: gapselect unit tests unsafe
[moodle.git] / question / type / numerical / tests / walkthrough_test.php
index 0d95cc0..e6fc43a 100644 (file)
@@ -186,7 +186,6 @@ class qtype_numerical_walkthrough_test extends qbehaviour_walkthrough_test_base
         $this->start_attempt_at_question($q, 'deferredfeedback', 1);
 
         $unitchoices = array(
-            '' => get_string('choosedots'),
             'm' => 'm',
             'cm' => 'cm',
         );
@@ -198,9 +197,10 @@ class qtype_numerical_walkthrough_test extends qbehaviour_walkthrough_test_base
                 $this->get_contains_marked_out_of_summary(),
                 $this->get_does_not_contain_feedback_expectation(),
                 $this->get_does_not_contain_validation_error_expectation(),
-                $this->get_contains_select_expectation('unit', $unitchoices, null, true),
                 $this->get_does_not_contain_try_again_button_expectation(),
                 $this->get_no_hint_visible_expectation());
+        $this->check_output_contains_selectoptions(
+                $this->get_contains_select_expectation('unit', $unitchoices, null, true));
 
         // Submit blank.
         $this->process_submission(array('answer' => ''));
@@ -212,9 +212,10 @@ class qtype_numerical_walkthrough_test extends qbehaviour_walkthrough_test_base
                 $this->get_contains_marked_out_of_summary(),
                 $this->get_does_not_contain_feedback_expectation(),
                 $this->get_does_not_contain_validation_error_expectation(),
-                $this->get_contains_select_expectation('unit', $unitchoices, null, true),
                 $this->get_does_not_contain_try_again_button_expectation(),
                 $this->get_no_hint_visible_expectation());
+        $this->check_output_contains_selectoptions(
+                $this->get_contains_select_expectation('unit', $unitchoices, null, true));
 
         // Sumit something that does not look like a number, but with a unit.
         $this->process_submission(array('answer' => 'newt', 'unit' => 'cm'));
@@ -228,9 +229,10 @@ class qtype_numerical_walkthrough_test extends qbehaviour_walkthrough_test_base
                 $this->get_contains_validation_error_expectation(),
                 new question_pattern_expectation('/' .
                         preg_quote(get_string('invalidnumber', 'qtype_numerical'), '/') . '/'),
-                $this->get_contains_select_expectation('unit', $unitchoices, 'cm', true),
                 $this->get_does_not_contain_try_again_button_expectation(),
                 $this->get_no_hint_visible_expectation());
+        $this->check_output_contains_selectoptions(
+                $this->get_contains_select_expectation('unit', $unitchoices, 'cm', true));
 
         // Now put in the right answer but without a unit.
         $this->process_submission(array('answer' => '1.25', 'unit' => ''));
@@ -243,9 +245,10 @@ class qtype_numerical_walkthrough_test extends qbehaviour_walkthrough_test_base
                 $this->get_contains_validation_error_expectation(),
                 new question_pattern_expectation('/' .
                         preg_quote(get_string('unitnotselected', 'qtype_numerical'), '/') . '/'),
-                $this->get_contains_select_expectation('unit', $unitchoices, '', true),
                 $this->get_does_not_contain_try_again_button_expectation(),
                 $this->get_no_hint_visible_expectation());
+        $this->check_output_contains_selectoptions(
+                $this->get_contains_select_expectation('unit', $unitchoices, '', true));
 
         // Now put in the right answer with a unit.
         $this->process_submission(array('answer' => '1.25', 'unit' => 'm'));
@@ -256,9 +259,10 @@ class qtype_numerical_walkthrough_test extends qbehaviour_walkthrough_test_base
                 $this->get_contains_marked_out_of_summary(),
                 $this->get_does_not_contain_feedback_expectation(),
                 $this->get_does_not_contain_validation_error_expectation(),
-                $this->get_contains_select_expectation('unit', $unitchoices, 'm', true),
                 $this->get_does_not_contain_try_again_button_expectation(),
                 $this->get_no_hint_visible_expectation());
+        $this->check_output_contains_selectoptions(
+                $this->get_contains_select_expectation('unit', $unitchoices, 'm', true));
 
         // Submit all and finish.
         $this->finish();
@@ -270,8 +274,9 @@ class qtype_numerical_walkthrough_test extends qbehaviour_walkthrough_test_base
                 $this->get_contains_mark_summary(1),
                 $this->get_contains_correct_expectation(),
                 $this->get_does_not_contain_validation_error_expectation(),
-                $this->get_contains_select_expectation('unit', $unitchoices, 'm', false),
                 $this->get_no_hint_visible_expectation());
+        $this->check_output_contains_selectoptions(
+                $this->get_contains_select_expectation('unit', $unitchoices, 'm', false));
         $this->assertEquals('1.25 m',
                 $this->quba->get_response_summary($this->slot));
     }