Proyectos de Subversion Moodle

Rev

Rev 11 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 11 Rev 1441
Línea 26... Línea 26...
26
 * @category   test
26
 * @category   test
27
 * @copyright  2022 Ferran Recio <ferran@moodle.com>
27
 * @copyright  2022 Ferran Recio <ferran@moodle.com>
28
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
29
 * @coversDefaultClass \mod_assign\downloader
29
 * @coversDefaultClass \mod_assign\downloader
30
 */
30
 */
31
class downloader_test extends \advanced_testcase {
31
final class downloader_test extends \advanced_testcase {
32
    /**
32
    /**
33
     * Setup to ensure that fixtures are loaded.
33
     * Setup to ensure that fixtures are loaded.
34
     */
34
     */
35
    public static function setupBeforeClass(): void {
35
    public static function setupBeforeClass(): void {
36
        global $CFG;
36
        global $CFG;
Línea 114... Línea 114...
114
            if ($key == 'student5') {
114
            if ($key == 'student5') {
115
                continue;
115
                continue;
116
            }
116
            }
117
            $datagenerator->create_submission([
117
            $datagenerator->create_submission([
118
                'userid' => $user->id,
118
                'userid' => $user->id,
119
                'assignid' => $cm->id,
119
                'cmid' => $cm->id,
120
                'file' => implode(',', $files),
120
                'file' => implode(',', $files),
121
            ]);
121
            ]);
122
        }
122
        }
Línea 123... Línea 123...
123
 
123
 
Línea 176... Línea 176...
176
    /**
176
    /**
177
     * Data provider for test_load_filelist().
177
     * Data provider for test_load_filelist().
178
     *
178
     *
179
     * @return array of scenarios
179
     * @return array of scenarios
180
     */
180
     */
181
    public function load_filelist_provider(): array {
181
    public static function load_filelist_provider(): array {
182
        $downloadasfoldertests = $this->load_filelist_downloadasfolder_scenarios();
182
        $downloadasfoldertests = static::load_filelist_downloadasfolder_scenarios();
183
        $downloadasfilestests = $this->load_filelist_downloadasfiles_scenarios();
183
        $downloadasfilestests = static::load_filelist_downloadasfiles_scenarios();
184
        return array_merge(
184
        return array_merge(
185
            $downloadasfoldertests,
185
            $downloadasfoldertests,
186
            $downloadasfilestests,
186
            $downloadasfilestests,
187
        );
187
        );
188
    }
188
    }
Línea 193... Línea 193...
193
     * The scenarios are the same as download as folder but replacing the "/" of the files
193
     * The scenarios are the same as download as folder but replacing the "/" of the files
194
     * by a "_" and setting the downloadasfolder to false.
194
     * by a "_" and setting the downloadasfolder to false.
195
     *
195
     *
196
     * @return array of scenarios
196
     * @return array of scenarios
197
     */
197
     */
198
    private function load_filelist_downloadasfiles_scenarios(): array {
198
    private static function load_filelist_downloadasfiles_scenarios(): array {
199
        $result = $this->load_filelist_downloadasfolder_scenarios("Download as files:");
199
        $result = static::load_filelist_downloadasfolder_scenarios("Download as files:");
200
        // Transform paths from files.
200
        // Transform paths from files.
201
        foreach ($result as $scenario => $info) {
201
        foreach ($result as $scenario => $info) {
202
            $info['downloadasfolder'] = false;
202
            $info['downloadasfolder'] = false;
203
            foreach ($info['expected'] as $key => $path) {
203
            foreach ($info['expected'] as $key => $path) {
204
                $info['expected'][$key] = str_replace('/', '_', $path);
204
                $info['expected'][$key] = str_replace('/', '_', $path);
Línea 212... Línea 212...
212
     * Generate the standard test scenarios for load_filelist with download as folder.
212
     * Generate the standard test scenarios for load_filelist with download as folder.
213
     *
213
     *
214
     * @param string $prefix the scenarios prefix
214
     * @param string $prefix the scenarios prefix
215
     * @return array of scenarios
215
     * @return array of scenarios
216
     */
216
     */
217
    private function load_filelist_downloadasfolder_scenarios(string $prefix = "Download as folders:"): array {
217
    private static function load_filelist_downloadasfolder_scenarios(
-
 
218
        string $prefix = "Download as folders:",
-
 
219
    ): array {
218
        return [
220
        return [
219
            // Test without team submissions.
221
            // Test without team submissions.
220
            $prefix . ' All users without groups' => [
222
            $prefix . ' All users without groups' => [
221
                'teamsubmission' => false,
223
                'teamsubmission' => false,
222
                'groupmembers' => [],
224
                'groupmembers' => [],