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

Need a better Behat step for testing downloads

XMLWordPrintable

      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.

            lameze Simey Lameze
            timhunt Tim Hunt
            Angelia Dela Cruz Angelia Dela Cruz
            Jun Pataleta Jun Pataleta
            CiBoT CiBoT
            Votes:
            4 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 3 days, 6 hours, 15 minutes
                3d 6h 15m

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