MDL-77333 mod_resource: fixes generator uploading files + tests
commit87fbf39aaeb581c96bb7c5ee42e20564b9e99b58
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Sat, 25 Mar 2023 12:43:55 +0000 (25 13:43 +0100)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Tue, 28 Mar 2023 17:06:26 +0000 (28 19:06 +0200)
tree70ae78885cc4af1624e41315d96f0a64412bbfce
parent6273e6fdf337943559d53125015dbeb091cad1d3
MDL-77333 mod_resource: fixes generator uploading files + tests

MDL-76499 revealed a few problems with resource generators:

1. We were not covering with unit tests the upload of files from disk
   (and here it's where the problem was).
2. There was a little of confusion between disk paths (only needed
   to upload files) and file_area paths (the generator only creates
   or uploads files to the root directory of the file area.
3. It was possible to request the upload of a file to the generator
   without that file effectively existing.

This commit fixes those points  and covers 99% of the generator code.
mod/resource/tests/generator/lib.php
mod/resource/tests/generator_test.php