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

Need a better Behat step for testing downloads



      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.


        Issue Links



              lameze Simey Lameze
              timhunt Tim Hunt
              4 Vote for this issue
              2 Start watching this issue



                Time Tracking

                  Original Estimate - Not Specified
                  Not Specified
                  Remaining Estimate - 0 minutes
                  Time Spent - 1 day, 1 hour, 39 minutes
                  1d 1h 39m


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