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

Need a better Behat step for testing downloads

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.4.5, 3.5.2
    • Fix Version/s: None
    • Labels:
      None
    • Affected Branches:
      MOODLE_34_STABLE, MOODLE_35_STABLE

      Description

      Currently we have a very limited Behat step:

      Then following "click here" should download between "1000" and "1200" bytes

      It was created by sam marshall and added to standard Moodle by Tim Hunt. At the time was the only think they could think of to allow some sort of test of downloads - just a basic test that the download gave something, not an error.

      However, it is horribly fragile. See, for example, the issues found in testing of MDL-23545 and MDL-63165.

      If you look at the implementation of the current step, it just uses download_file_content on the URL from the link followed, then just tests strlen($result).

      However, that means it would not be hard to implement better tests. I am thinking of a step like:

      bq. Then following "click here" should download a file that:
         | Contains                    | <question type="truefalse"> |
         | Contains regexp             | ~<!-- question: \d+  -->~   |
         | Is well-formed XML          |                             |
         | Does not contain PHP errors |                             |
         | Has size at least           | 1K                          |
         | Has size at mose            | 1200                        |
      

      What do people think about that proposed form? (The idea is that it would be quite easy to add more tests later as we find we need them, and the last two there are, as already said, pretty useless, so are only really there for backwards compatibility.)

      I probably won't have time to work on this any time soon, so I would be delighed if someone else took it.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                timhunt Tim Hunt
                Participants:
                Component watchers:
                Andrew Nicols, Mathew May, Michael Hawkins, Shamim Rezaie, Simey Lameze
              • Votes:
                3 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated: