Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 51... Línea 51...
51
 
51
 
52
    /**
52
    /**
53
     * Ensure that get_conversions_for_file returns an existing conversion
53
     * Ensure that get_conversions_for_file returns an existing conversion
54
     * record with matching sourcefileid and targetformat.
54
     * record with matching sourcefileid and targetformat.
55
     */
55
     */
56
    public function test_get_conversions_for_file_existing_conversion_incomplete() {
56
    public function test_get_conversions_for_file_existing_conversion_incomplete(): void {
Línea 57... Línea 57...
57
        $this->resetAfterTest();
57
        $this->resetAfterTest();
Línea 58... Línea 58...
58
 
58
 
Línea 80... Línea 80...
80
     * record with matching sourcefileid and targetformat when a file with the same
80
     * record with matching sourcefileid and targetformat when a file with the same
81
     * contenthash is uploaded several times.
81
     * contenthash is uploaded several times.
82
     *
82
     *
83
     * @covers \core_files\conversion::get_conversions_for_file
83
     * @covers \core_files\conversion::get_conversions_for_file
84
     */
84
     */
85
    public function test_get_conversions_for_multiple_files_existing_conversion_incomplete() {
85
    public function test_get_conversions_for_multiple_files_existing_conversion_incomplete(): void {
86
        $this->resetAfterTest();
86
        $this->resetAfterTest();
Línea 87... Línea 87...
87
 
87
 
88
        // Create a bunch of files with the same content.
88
        // Create a bunch of files with the same content.
89
        for ($i = 0; $i < 5; $i++) {
89
        for ($i = 0; $i < 5; $i++) {
Línea 125... Línea 125...
125
    /**
125
    /**
126
     * Ensure that get_conversions_for_file returns an existing conversion
126
     * Ensure that get_conversions_for_file returns an existing conversion
127
     * record with matching sourcefileid and targetformat when a second
127
     * record with matching sourcefileid and targetformat when a second
128
     * conversion to a different format exists.
128
     * conversion to a different format exists.
129
     */
129
     */
130
    public function test_get_conversions_for_file_existing_conversion_multiple_formats_incomplete() {
130
    public function test_get_conversions_for_file_existing_conversion_multiple_formats_incomplete(): void {
131
        $this->resetAfterTest();
131
        $this->resetAfterTest();
Línea 132... Línea 132...
132
 
132
 
Línea 133... Línea 133...
133
        $sourcefile = $this->create_stored_file();
133
        $sourcefile = $this->create_stored_file();
Línea 157... Línea 157...
157
 
157
 
158
    /**
158
    /**
159
     * Ensure that get_conversions_for_file returns an existing conversion
159
     * Ensure that get_conversions_for_file returns an existing conversion
160
     * record with matching sourcefileid and targetformat.
160
     * record with matching sourcefileid and targetformat.
161
     */
161
     */
162
    public function test_get_conversions_for_file_existing_conversion_complete() {
162
    public function test_get_conversions_for_file_existing_conversion_complete(): void {
Línea 163... Línea 163...
163
        $this->resetAfterTest();
163
        $this->resetAfterTest();
164
 
164
 
165
        $sourcefile = $this->create_stored_file();
165
        $sourcefile = $this->create_stored_file();
Línea 193... Línea 193...
193
 
193
 
194
    /**
194
    /**
195
     * Ensure that get_conversions_for_file returns an existing conversion
195
     * Ensure that get_conversions_for_file returns an existing conversion
196
     * record with matching sourcefileid and targetformat.
196
     * record with matching sourcefileid and targetformat.
197
     */
197
     */
198
    public function test_get_conversions_for_file_existing_conversion_multiple_formats_complete() {
198
    public function test_get_conversions_for_file_existing_conversion_multiple_formats_complete(): void {
Línea 199... Línea 199...
199
        $this->resetAfterTest();
199
        $this->resetAfterTest();
200
 
200
 
201
        $sourcefile = $this->create_stored_file();
201
        $sourcefile = $this->create_stored_file();
Línea 234... Línea 234...
234
 
234
 
235
    /**
235
    /**
236
     * Ensure that get_conversions_for_file returns an existing conversion
236
     * Ensure that get_conversions_for_file returns an existing conversion
237
     * record does not exist, but the file has previously been converted.
237
     * record does not exist, but the file has previously been converted.
238
     */
238
     */
239
    public function test_get_conversions_for_file_existing_target() {
239
    public function test_get_conversions_for_file_existing_target(): void {
Línea 240... Línea 240...
240
        $this->resetAfterTest();
240
        $this->resetAfterTest();
241
 
241
 
242
        $sourcefile = $this->create_stored_file();
242
        $sourcefile = $this->create_stored_file();
Línea 261... Línea 261...
261
    }
261
    }
Línea 262... Línea 262...
262
 
262
 
263
    /**
263
    /**
264
     * Ensure that set_sourcefile sets the correct fileid.
264
     * Ensure that set_sourcefile sets the correct fileid.
265
     */
265
     */
266
    public function test_set_sourcefile() {
266
    public function test_set_sourcefile(): void {
Línea 267... Línea 267...
267
        $this->resetAfterTest();
267
        $this->resetAfterTest();
268
 
268
 
Línea 276... Línea 276...
276
    }
276
    }
Línea 277... Línea 277...
277
 
277
 
278
    /**
278
    /**
279
     * Ensure that store_destfile_from_path stores the file as expected.
279
     * Ensure that store_destfile_from_path stores the file as expected.
280
     */
280
     */
281
    public function test_store_destfile_from_path() {
281
    public function test_store_destfile_from_path(): void {
Línea 282... Línea 282...
282
        $this->resetAfterTest();
282
        $this->resetAfterTest();
283
 
283
 
284
        $sourcefile = $this->create_stored_file();
284
        $sourcefile = $this->create_stored_file();
Línea 295... Línea 295...
295
    }
295
    }
Línea 296... Línea 296...
296
 
296
 
297
    /**
297
    /**
298
     * Ensure that store_destfile_from_path stores the file as expected.
298
     * Ensure that store_destfile_from_path stores the file as expected.
299
     */
299
     */
300
    public function test_store_destfile_from_path_delete_existing() {
300
    public function test_store_destfile_from_path_delete_existing(): void {
Línea 301... Línea 301...
301
        $this->resetAfterTest();
301
        $this->resetAfterTest();
302
 
302
 
303
        $sourcefile = $this->create_stored_file();
303
        $sourcefile = $this->create_stored_file();
Línea 323... Línea 323...
323
    }
323
    }
Línea 324... Línea 324...
324
 
324
 
325
    /**
325
    /**
326
     * Ensure that store_destfile_from_path stores the file as expected.
326
     * Ensure that store_destfile_from_path stores the file as expected.
327
     */
327
     */
328
    public function test_store_destfile_from_string() {
328
    public function test_store_destfile_from_string(): void {
Línea 329... Línea 329...
329
        $this->resetAfterTest();
329
        $this->resetAfterTest();
330
 
330
 
331
        $sourcefile = $this->create_stored_file();
331
        $sourcefile = $this->create_stored_file();
Línea 343... Línea 343...
343
 
343
 
344
    /**
344
    /**
345
     * Ensure that store_destfile_from_string stores the file as expected when
345
     * Ensure that store_destfile_from_string stores the file as expected when
346
     * an existing destfile is found.
346
     * an existing destfile is found.
347
     */
347
     */
348
    public function test_store_destfile_from_string_delete_existing() {
348
    public function test_store_destfile_from_string_delete_existing(): void {
Línea 349... Línea 349...
349
        $this->resetAfterTest();
349
        $this->resetAfterTest();
350
 
350
 
351
        $sourcefile = $this->create_stored_file();
351
        $sourcefile = $this->create_stored_file();
Línea 371... Línea 371...
371
    }
371
    }
Línea 372... Línea 372...
372
 
372
 
373
    /**
373
    /**
374
     * Ensure that the get_status functions cast the status to integer correctly.
374
     * Ensure that the get_status functions cast the status to integer correctly.
375
     */
375
     */
376
    public function test_get_status() {
376
    public function test_get_status(): void {
377
        $conversion = new conversion(0, (object) [
377
        $conversion = new conversion(0, (object) [
378
            'status' => (string) 1,
378
            'status' => (string) 1,
Línea 379... Línea 379...
379
        ]);
379
        ]);
380
 
380
 
Línea 381... Línea 381...
381
        $this->assertIsInt($conversion->get('status'));
381
        $this->assertIsInt($conversion->get('status'));
382
    }
382
    }
383
 
383
 
384
    /**
384
    /**
385
     * Ensure that get_converter_instance returns false when no converter is set.
385
     * Ensure that get_converter_instance returns false when no converter is set.
386
     */
386
     */
387
    public function test_get_converter_instance_none_set() {
387
    public function test_get_converter_instance_none_set(): void {
Línea 388... Línea 388...
388
        $conversion = new conversion(0, (object) []);
388
        $conversion = new conversion(0, (object) []);
389
        $this->assertFalse($conversion->get_converter_instance());
389
        $this->assertFalse($conversion->get_converter_instance());
390
    }
390
    }
391
 
391
 
392
    /**
392
    /**
393
     * Ensure that get_converter_instance returns false when no valid converter is set.
393
     * Ensure that get_converter_instance returns false when no valid converter is set.
394
     */
394
     */
395
    public function test_get_converter_instance_invalid_set() {
395
    public function test_get_converter_instance_invalid_set(): void {
396
        $conversion = new conversion(0, (object) [
396
        $conversion = new conversion(0, (object) [
Línea 397... Línea 397...
397
            'converter' => '\\fileconverter_not_a_valid_converter\\converter',
397
            'converter' => '\\fileconverter_not_a_valid_converter\\converter',
398
        ]);
398
        ]);
399
        $this->assertFalse($conversion->get_converter_instance());
399
        $this->assertFalse($conversion->get_converter_instance());
400
    }
400
    }
401
 
401
 
402
    /**
402
    /**
403
     * Ensure that get_converter_instance returns an instance when a valid converter is set.
403
     * Ensure that get_converter_instance returns an instance when a valid converter is set.
404
     */
404
     */
405
    public function test_get_converter_instance_valid_set() {
405
    public function test_get_converter_instance_valid_set(): void {
Línea 406... Línea 406...
406
        $conversion = new conversion(0, (object) [
406
        $conversion = new conversion(0, (object) [
407
            'converter' => \fileconverter_unoconv\converter::class,
407
            'converter' => \fileconverter_unoconv\converter::class,
408
        ]);
408
        ]);
409
        $this->assertInstanceOf(\fileconverter_unoconv\converter::class, $conversion->get_converter_instance());
409
        $this->assertInstanceOf(\fileconverter_unoconv\converter::class, $conversion->get_converter_instance());
410
    }
410
    }
411
 
411
 
Línea 412... Línea 412...
412
    /**
412
    /**
413
     * Test that all old conversion records are removed periodically.
413
     * Test that all old conversion records are removed periodically.
Línea 430... Línea 430...
430
    }
430
    }
Línea 431... Línea 431...
431
 
431
 
432
    /**
432
    /**
433
     * Test that all old conversion records are removed periodically.
433
     * Test that all old conversion records are removed periodically.
434
     */
434
     */
435
    public function test_remove_old_conversion_records_young() {
435
    public function test_remove_old_conversion_records_young(): void {
436
        $this->resetAfterTest();
436
        $this->resetAfterTest();
Línea 437... Línea 437...
437
        global $DB;
437
        global $DB;
438
 
438
 
Línea 450... Línea 450...
450
    }
450
    }
Línea 451... Línea 451...
451
 
451
 
452
    /**
452
    /**
453
     * Test orphan records are removed.
453
     * Test orphan records are removed.
454
     */
454
     */
455
    public function test_remove_orphan_records() {
455
    public function test_remove_orphan_records(): void {
456
        global $DB;
456
        global $DB;
Línea 457... Línea 457...
457
        $this->resetAfterTest();
457
        $this->resetAfterTest();
458
 
458