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

    Details

    • Testing Instructions:
      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.
    • Difficulty:
      Easy
    • Affected Branches:
      MOODLE_27_STABLE
    • Fixed Branches:
      MOODLE_27_STABLE
    • Pull from Repository:

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              timhunt Tim Hunt
              Reporter:
              timhunt Tim Hunt
              Peer reviewer:
              Rajesh Taneja
              Integrator:
              Eloy Lafuente (stronk7)
              Tester:
              David Monllaó
              Participants:
              Component watchers:
              Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                2/Feb/15