Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 1441
Línea 88... Línea 88...
88
        $file2 = $method->invoke(null, $assign, $user->id, 1, $imageresource, 'testimage.png');
88
        $file2 = $method->invoke(null, $assign, $user->id, 1, $imageresource, 'testimage.png');
89
        $this->assertEquals($file1->get_id(), $file2->get_id());
89
        $this->assertEquals($file1->get_id(), $file2->get_id());
90
    }
90
    }
Línea 91... Línea 91...
91
 
91
 
-
 
92
    /**
-
 
93
     * Test that save_jpg_to_pdf() method safely rejects a non-JPEG file with a JPEG extension.
-
 
94
     */
-
 
95
    public function test_save_jpg_to_pdf_rejects_non_jpeg(): void {
-
 
96
        $this->resetAfterTest();
-
 
97
 
-
 
98
        $course = $this->getDataGenerator()->create_course();
-
 
99
        $generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
-
 
100
        $user = $this->getDataGenerator()->create_and_enrol($course);
-
 
101
 
-
 
102
        $assign = $this->create_instance($course, [
-
 
103
            'assignsubmission_file_enabled' => 1,
-
 
104
            'assignsubmission_file_maxfiles' => 1,
-
 
105
            'assignsubmission_file_maxsizebytes' => 1024 * 1024,
-
 
106
        ]);
-
 
107
        $fileplugin = $assign->get_plugin_by_type('assignsubmission', 'file');
-
 
108
        $generator->create_submission([
-
 
109
            'userid' => $user->id,
-
 
110
            'cmid' => $assign->get_course_module()->id,
-
 
111
            'file' => 'mod/assign/feedback/editpdf/tests/fixtures/heic.jpg',
-
 
112
        ]);
-
 
113
        $submission = $assign->get_user_submission($user->id, false);
-
 
114
        $files = $fileplugin->get_files($submission, $user);
-
 
115
        $this->assertEquals('image/jpeg', $files['/heic.jpg']->get_mimetype());
-
 
116
 
-
 
117
        // Invoke the save_jpg_to_pdf method expecting there to be no exceptions.
-
 
118
        $method = new \ReflectionMethod('\assignfeedback_editpdf\document_services', 'save_jpg_to_pdf');
-
 
119
        $retfile = $method->invoke(null, $assign, $user->id, 1, $files['/heic.jpg']);
-
 
120
        $this->assertNull($retfile);
-
 
121
        $this->assertDebuggingCalled("Could not convert {$files['/heic.jpg']->get_contenthash()} jpg to pdf: " .
-
 
122
            "TCPDF ERROR: [Image] Unable to get the size of the image: ", DEBUG_ALL);
-
 
123
    }
-
 
124
 
92
    /**
125
    /**
93
     * Test that get_combined_document_for_attempt() method rotates the image only once.
126
     * Test that get_combined_document_for_attempt() method rotates the image only once.
94
     */
127
     */
95
    public function test_get_combined_document_for_attempt_rotates_image(): void {
128
    public function test_get_combined_document_for_attempt_rotates_image(): void {
96
        global $CFG, $DB;
129
        global $CFG, $DB;