Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 153... Línea 153...
153
    }
153
    }
Línea 154... Línea 154...
154
 
154
 
155
    /**
155
    /**
156
     * Test the start_conversion function.
156
     * Test the start_conversion function.
157
     */
157
     */
158
    public function test_start_conversion_existing_single() {
158
    public function test_start_conversion_existing_single(): void {
Línea 159... Línea 159...
159
        $this->resetAfterTest();
159
        $this->resetAfterTest();
Línea 160... Línea 160...
160
 
160
 
Línea 174... Línea 174...
174
    }
174
    }
Línea 175... Línea 175...
175
 
175
 
176
    /**
176
    /**
177
     * Test the start_conversion function.
177
     * Test the start_conversion function.
178
     */
178
     */
179
    public function test_start_conversion_existing_multiple() {
179
    public function test_start_conversion_existing_multiple(): void {
Línea 180... Línea 180...
180
        $this->resetAfterTest();
180
        $this->resetAfterTest();
Línea 181... Línea 181...
181
 
181
 
Línea 202... Línea 202...
202
    }
202
    }
Línea 203... Línea 203...
203
 
203
 
204
    /**
204
    /**
205
     * Test the start_conversion function.
205
     * Test the start_conversion function.
206
     */
206
     */
207
    public function test_start_conversion_no_existing() {
207
    public function test_start_conversion_no_existing(): void {
Línea 208... Línea 208...
208
        $this->resetAfterTest();
208
        $this->resetAfterTest();
Línea 209... Línea 209...
209
 
209
 
Línea 216... Línea 216...
216
    }
216
    }
Línea 217... Línea 217...
217
 
217
 
218
    /**
218
    /**
219
     * Test the get_document_converter_classes function with no enabled plugins.
219
     * Test the get_document_converter_classes function with no enabled plugins.
220
     */
220
     */
221
    public function test_get_document_converter_classes_no_plugins() {
221
    public function test_get_document_converter_classes_no_plugins(): void {
222
        $converter = $this->get_testable_mock(['get_enabled_plugins']);
222
        $converter = $this->get_testable_mock(['get_enabled_plugins']);
Línea 223... Línea 223...
223
        $converter->method('get_enabled_plugins')->willReturn([]);
223
        $converter->method('get_enabled_plugins')->willReturn([]);
224
 
224
 
Línea 228... Línea 228...
228
    }
228
    }
Línea 229... Línea 229...
229
 
229
 
230
    /**
230
    /**
231
     * Test the get_document_converter_classes function when no class was found.
231
     * Test the get_document_converter_classes function when no class was found.
232
     */
232
     */
233
    public function test_get_document_converter_classes_plugin_class_not_found() {
233
    public function test_get_document_converter_classes_plugin_class_not_found(): void {
234
        $converter = $this->get_testable_mock(['get_enabled_plugins']);
234
        $converter = $this->get_testable_mock(['get_enabled_plugins']);
235
        $converter->method('get_enabled_plugins')->willReturn([
235
        $converter->method('get_enabled_plugins')->willReturn([
236
                'noplugin' => '\not\a\real\plugin',
236
                'noplugin' => '\not\a\real\plugin',
Línea 242... Línea 242...
242
    }
242
    }
Línea 243... Línea 243...
243
 
243
 
244
    /**
244
    /**
245
     * Test the get_document_converter_classes function when the returned classes do not meet requirements.
245
     * Test the get_document_converter_classes function when the returned classes do not meet requirements.
246
     */
246
     */
247
    public function test_get_document_converter_classes_plugin_class_requirements_not_met() {
247
    public function test_get_document_converter_classes_plugin_class_requirements_not_met(): void {
248
        $plugin = $this->getMockBuilder(\core_file_converter_requirements_not_met::class)
248
        $plugin = $this->getMockBuilder(\core_file_converter_requirements_not_met::class)
249
            ->onlyMethods([])
249
            ->onlyMethods([])
Línea 250... Línea 250...
250
            ->getMock();
250
            ->getMock();
Línea 260... Línea 260...
260
    }
260
    }
Línea 261... Línea 261...
261
 
261
 
262
    /**
262
    /**
263
     * Test the get_document_converter_classes function when the returned classes do not meet requirements.
263
     * Test the get_document_converter_classes function when the returned classes do not meet requirements.
264
     */
264
     */
265
    public function test_get_document_converter_classes_plugin_class_met_not_supported() {
265
    public function test_get_document_converter_classes_plugin_class_met_not_supported(): void {
266
        $plugin = $this->getMockBuilder(\core_file_converter_type_not_supported::class)
266
        $plugin = $this->getMockBuilder(\core_file_converter_type_not_supported::class)
267
            ->onlyMethods([])
267
            ->onlyMethods([])
Línea 268... Línea 268...
268
            ->getMock();
268
            ->getMock();
Línea 278... Línea 278...
278
    }
278
    }
Línea 279... Línea 279...
279
 
279
 
280
    /**
280
    /**
281
     * Test the get_document_converter_classes function when the returned classes do not meet requirements.
281
     * Test the get_document_converter_classes function when the returned classes do not meet requirements.
282
     */
282
     */
283
    public function test_get_document_converter_classes_plugin_class_met_and_supported() {
283
    public function test_get_document_converter_classes_plugin_class_met_and_supported(): void {
284
        $plugin = $this->getMockBuilder(\core_file_converter_type_supported::class)
284
        $plugin = $this->getMockBuilder(\core_file_converter_type_supported::class)
285
            ->onlyMethods([])
285
            ->onlyMethods([])
286
            ->getMock();
286
            ->getMock();
Línea 298... Línea 298...
298
    }
298
    }
Línea 299... Línea 299...
299
 
299
 
300
    /**
300
    /**
301
     * Test the can_convert_storedfile_to function with a directory.
301
     * Test the can_convert_storedfile_to function with a directory.
302
     */
302
     */
303
    public function test_can_convert_storedfile_to_directory() {
303
    public function test_can_convert_storedfile_to_directory(): void {
Línea 304... Línea 304...
304
        $converter = $this->get_testable_mock();
304
        $converter = $this->get_testable_mock();
305
 
305
 
Línea 310... Línea 310...
310
    }
310
    }
Línea 311... Línea 311...
311
 
311
 
312
    /**
312
    /**
313
     * Test the can_convert_storedfile_to function with an empty file.
313
     * Test the can_convert_storedfile_to function with an empty file.
314
     */
314
     */
315
    public function test_can_convert_storedfile_to_emptyfile() {
315
    public function test_can_convert_storedfile_to_emptyfile(): void {
Línea 316... Línea 316...
316
        $converter = $this->get_testable_mock();
316
        $converter = $this->get_testable_mock();
317
 
317
 
Línea 322... Línea 322...
322
    }
322
    }
Línea 323... Línea 323...
323
 
323
 
324
    /**
324
    /**
325
     * Test the can_convert_storedfile_to function with a file with indistinguished mimetype.
325
     * Test the can_convert_storedfile_to function with a file with indistinguished mimetype.
326
     */
326
     */
327
    public function test_can_convert_storedfile_to_no_mimetype() {
327
    public function test_can_convert_storedfile_to_no_mimetype(): void {
Línea 328... Línea 328...
328
        $converter = $this->get_testable_mock();
328
        $converter = $this->get_testable_mock();
329
 
329
 
330
        // A file with filename '.' is a directory.
330
        // A file with filename '.' is a directory.
Línea 336... Línea 336...
336
    }
336
    }
Línea 337... Línea 337...
337
 
337
 
338
    /**
338
    /**
339
     * Test the can_convert_storedfile_to function with a file with a known mimetype and extension.
339
     * Test the can_convert_storedfile_to function with a file with a known mimetype and extension.
340
     */
340
     */
341
    public function test_can_convert_storedfile_to_docx() {
341
    public function test_can_convert_storedfile_to_docx(): void {
Línea 342... Línea 342...
342
        $returnvalue = (object) [];
342
        $returnvalue = (object) [];
343
 
343
 
344
        $converter = $this->get_testable_mock([
344
        $converter = $this->get_testable_mock([
Línea 361... Línea 361...
361
 
361
 
362
 
362
 
363
    /**
363
    /**
364
     * Test the can_convert_format_to function.
364
     * Test the can_convert_format_to function.
365
     */
365
     */
Línea 366... Línea 366...
366
    public function test_can_convert_format_to_found() {
366
    public function test_can_convert_format_to_found(): void {
Línea 367... Línea 367...
367
        $converter = $this->get_testable_mock(['get_document_converter_classes']);
367
        $converter = $this->get_testable_mock(['get_document_converter_classes']);
Línea 376... Línea 376...
376
    }
376
    }
Línea 377... Línea 377...
377
 
377
 
378
    /**
378
    /**
379
     * Test the can_convert_format_to function.
379
     * Test the can_convert_format_to function.
380
     */
380
     */
381
    public function test_can_convert_format_to_not_found() {
381
    public function test_can_convert_format_to_not_found(): void {
Línea 382... Línea 382...
382
        $converter = $this->get_testable_mock(['get_document_converter_classes']);
382
        $converter = $this->get_testable_mock(['get_document_converter_classes']);
383
 
383
 
Línea 389... Línea 389...
389
    }
389
    }
Línea 390... Línea 390...
390
 
390
 
391
    /**
391
    /**
392
     * Test the can_convert_storedfile_to function with an empty file.
392
     * Test the can_convert_storedfile_to function with an empty file.
393
     */
393
     */
394
    public function test_poll_conversion_in_progress() {
394
    public function test_poll_conversion_in_progress(): void {
Línea 395... Línea 395...
395
        $this->resetAfterTest();
395
        $this->resetAfterTest();
396
 
396
 
397
        $converter = $this->get_testable_mock([
397
        $converter = $this->get_testable_mock([
Línea 427... Línea 427...
427
 
427
 
428
    /**
428
    /**
429
     * Test poll_conversion with an in-progress conversion where we are
429
     * Test poll_conversion with an in-progress conversion where we are
430
     * unable to instantiate the converter instance.
430
     * unable to instantiate the converter instance.
431
     */
431
     */
432
    public function test_poll_conversion_in_progress_fail() {
432
    public function test_poll_conversion_in_progress_fail(): void {
Línea 433... Línea 433...
433
        $this->resetAfterTest();
433
        $this->resetAfterTest();
434
 
434
 
435
        $converter = $this->get_testable_mock([
435
        $converter = $this->get_testable_mock([
Línea 459... Línea 459...
459
    }
459
    }
Línea 460... Línea 460...
460
 
460
 
461
    /**
461
    /**
462
     * Test the can_convert_storedfile_to function with an empty file.
462
     * Test the can_convert_storedfile_to function with an empty file.
463
     */
463
     */
464
    public function test_poll_conversion_none_supported() {
464
    public function test_poll_conversion_none_supported(): void {
Línea 465... Línea 465...
465
        $this->resetAfterTest();
465
        $this->resetAfterTest();
466
 
466
 
467
        $converter = $this->get_testable_mock([
467
        $converter = $this->get_testable_mock([
Línea 487... Línea 487...
487
    }
487
    }
Línea 488... Línea 488...
488
 
488
 
489
    /**
489
    /**
490
     * Test the can_convert_storedfile_to function with an empty file.
490
     * Test the can_convert_storedfile_to function with an empty file.
491
     */
491
     */
492
    public function test_poll_conversion_pick_first() {
492
    public function test_poll_conversion_pick_first(): void {
Línea 493... Línea 493...
493
        $this->resetAfterTest();
493
        $this->resetAfterTest();
494
 
494
 
495
        $converterinstance = $this->get_mocked_converter([
495
        $converterinstance = $this->get_mocked_converter([
Línea 528... Línea 528...
528
    }
528
    }
Línea 529... Línea 529...
529
 
529
 
530
    /**
530
    /**
531
     * Test the can_convert_storedfile_to function with an empty file.
531
     * Test the can_convert_storedfile_to function with an empty file.
532
     */
532
     */
533
    public function test_poll_conversion_pick_subsequent() {
533
    public function test_poll_conversion_pick_subsequent(): void {
Línea 534... Línea 534...
534
        $this->resetAfterTest();
534
        $this->resetAfterTest();
535
 
535
 
536
        $converterinstance = $this->get_mocked_converter([
536
        $converterinstance = $this->get_mocked_converter([
Línea 601... Línea 601...
601
    }
601
    }
Línea 602... Línea 602...
602
 
602
 
603
    /**
603
    /**
604
     * Test the start_conversion with a single converter which succeeds.
604
     * Test the start_conversion with a single converter which succeeds.
605
     */
605
     */
606
    public function test_start_conversion_one_supported_success() {
606
    public function test_start_conversion_one_supported_success(): void {
Línea 607... Línea 607...
607
        $this->resetAfterTest();
607
        $this->resetAfterTest();
608
 
608
 
609
        $converter = $this->get_testable_mock([
609
        $converter = $this->get_testable_mock([
Línea 623... Línea 623...
623
    }
623
    }
Línea 624... Línea 624...
624
 
624
 
625
    /**
625
    /**
626
     * Test the start_conversion with a single converter which failes.
626
     * Test the start_conversion with a single converter which failes.
627
     */
627
     */
628
    public function test_start_conversion_one_supported_failure() {
628
    public function test_start_conversion_one_supported_failure(): void {
Línea 629... Línea 629...
629
        $this->resetAfterTest();
629
        $this->resetAfterTest();
630
 
630
 
631
        $converter = $this->get_testable_mock([
631
        $converter = $this->get_testable_mock([
Línea 646... Línea 646...
646
    }
646
    }
Línea 647... Línea 647...
647
 
647
 
648
    /**
648
    /**
649
     * Test the start_conversion with two converters - fail, then succeed.
649
     * Test the start_conversion with two converters - fail, then succeed.
650
     */
650
     */
651
    public function test_start_conversion_two_supported() {
651
    public function test_start_conversion_two_supported(): void {
Línea 652... Línea 652...
652
        $this->resetAfterTest();
652
        $this->resetAfterTest();
653
 
653
 
654
        $converter = $this->get_testable_mock([
654
        $converter = $this->get_testable_mock([
Línea 672... Línea 672...
672
    }
672
    }
Línea 673... Línea 673...
673
 
673
 
674
    /**
674
    /**
675
     * Ensure that get_next_converter returns false when no converters are available.
675
     * Ensure that get_next_converter returns false when no converters are available.
676
     */
676
     */
677
    public function test_get_next_converter_no_converters() {
677
    public function test_get_next_converter_no_converters(): void {
Línea 678... Línea 678...
678
        $rcm = new \ReflectionMethod(converter::class, 'get_next_converter');
678
        $rcm = new \ReflectionMethod(converter::class, 'get_next_converter');
679
 
679
 
680
        $converter = new \core_files\converter();
680
        $converter = new \core_files\converter();
Línea 684... Línea 684...
684
 
684
 
685
    /**
685
    /**
686
     * Ensure that get_next_converter returns false when already on the
686
     * Ensure that get_next_converter returns false when already on the
687
     * only converter.
687
     * only converter.
688
     */
688
     */
689
    public function test_get_next_converter_only_converters() {
689
    public function test_get_next_converter_only_converters(): void {
Línea 690... Línea 690...
690
        $rcm = new \ReflectionMethod(converter::class, 'get_next_converter');
690
        $rcm = new \ReflectionMethod(converter::class, 'get_next_converter');
691
 
691
 
692
        $converter = new converter();
692
        $converter = new converter();
Línea 696... Línea 696...
696
 
696
 
697
    /**
697
    /**
698
     * Ensure that get_next_converter returns false when already on the
698
     * Ensure that get_next_converter returns false when already on the
699
     * last converter.
699
     * last converter.
700
     */
700
     */
701
    public function test_get_next_converter_last_converters() {
701
    public function test_get_next_converter_last_converters(): void {
Línea 702... Línea 702...
702
        $rcm = new \ReflectionMethod(converter::class, 'get_next_converter');
702
        $rcm = new \ReflectionMethod(converter::class, 'get_next_converter');
703
 
703
 
704
        $converter = new converter();
704
        $converter = new converter();
Línea 708... Línea 708...
708
 
708
 
709
    /**
709
    /**
710
     * Ensure that get_next_converter returns the next vlaue when in a
710
     * Ensure that get_next_converter returns the next vlaue when in a
711
     * current converter.
711
     * current converter.
712
     */
712
     */
713
    public function test_get_next_converter_middle_converters() {
713
    public function test_get_next_converter_middle_converters(): void {
Línea 714... Línea 714...
714
        $rcm = new \ReflectionMethod(converter::class, 'get_next_converter');
714
        $rcm = new \ReflectionMethod(converter::class, 'get_next_converter');
715
 
715
 
716
        $converter = new converter();
716
        $converter = new converter();
Línea 720... Línea 720...
720
    /**
720
    /**
721
     *
721
     *
722
     * Ensure that get_next_converter returns the next vlaue when in a
722
     * Ensure that get_next_converter returns the next vlaue when in a
723
     * current converter.
723
     * current converter.
724
     */
724
     */
725
    public function test_get_next_converter_first() {
725
    public function test_get_next_converter_first(): void {
726
        $rcm = new \ReflectionMethod(converter::class, 'get_next_converter');
726
        $rcm = new \ReflectionMethod(converter::class, 'get_next_converter');
Línea 727... Línea 727...
727
 
727
 
728
        $converter = new converter();
728
        $converter = new converter();
729
        $result = $rcm->invoke($converter, ['foo', 'bar', 'baz', 'example']);
729
        $result = $rcm->invoke($converter, ['foo', 'bar', 'baz', 'example']);