Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-48860

Behat tests checking the value of selects do not work properly in 2.7

XMLWordPrintable

    • MOODLE_27_STABLE
    • MOODLE_27_STABLE
    • Easy
    • Hide
      1. Run the grade/tests/behat/grade_point_maximum.feature test to verify this does not break back-wards compatibility.
      2. The testing instructions in MDL-48859 verify that this fix solves the problem.
      Show
      Run the grade/tests/behat/grade_point_maximum.feature test to verify this does not break back-wards compatibility. The testing instructions in MDL-48859 verify that this fix solves the problem.

      This is another problem I found testing https://github.com/timhunt/moodle-quizaccess_offlinemode in 2.7

      The answer is a selective backport of another bit of MDL-43835. If you look at the change there (https://github.com/moodle/moodle/commit/955118d831c31df145d238a68758009406c062cd) it seems like a backwards-incompatible change, changing selects from checking the value="" to checking the human-readable text. However, that is not true.

      You need to look more deeply at the code: https://github.com/moodle/moodle/blob/146c80d33818f22e5689d38abb4e08c64fa6bf62/lib/behat/form_field/behat_form_select.php#L201 you will see that it is already trying to match either the human-readable value, or the behind-the scenes value="" attribute. Note the two calls get_selected_options(true / false);

      So, this is just a straight bug, get_selected_options(true); was returning the wrong result, and back-porting the fix to that but is safe.

      As a verification, you can run one of the tests modified in that commit (e.g. grade/tests/behat/grade_point_maximum.feature which exists in 2.7) in unmodified form, and it still passes.

            timhunt Tim Hunt
            timhunt Tim Hunt
            Rajesh Taneja Rajesh Taneja
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            David Monllaó David Monllaó
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.