Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 1441
Línea 27... Línea 27...
27
 * @package    mod_data
27
 * @package    mod_data
28
 * @copyright  2023 ISB Bayern
28
 * @copyright  2023 ISB Bayern
29
 * @author     Philipp Memmel
29
 * @author     Philipp Memmel
30
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
30
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
31
 */
31
 */
32
class entries_export_test extends \advanced_testcase {
32
final class entries_export_test extends \advanced_testcase {
Línea 33... Línea 33...
33
 
33
 
34
    /**
34
    /**
35
     * Get the test data.
35
     * Get the test data.
36
     *
36
     *
Línea 128... Línea 128...
128
        // This means file and picture fields will be exported, but only as text (which is the filename),
128
        // This means file and picture fields will be exported, but only as text (which is the filename),
129
        // so we will receive a csv export file.
129
        // so we will receive a csv export file.
130
        $includefiles = false;
130
        $includefiles = false;
131
        utils::data_exportdata($data->id, $fields, $selectedfields, $exporter, $currentgroup, $context,
131
        utils::data_exportdata($data->id, $fields, $selectedfields, $exporter, $currentgroup, $context,
132
            $exportuser, $exporttime, $exportapproval, $tags, $includefiles);
132
            $exportuser, $exporttime, $exportapproval, $tags, $includefiles);
133
        $this->assertEquals(file_get_contents(__DIR__ . '/fixtures/test_data_export_without_files.csv'),
133
        $this->assertEquals(file_get_contents(self::get_fixture_path(__NAMESPACE__, 'test_data_export_without_files.csv')),
134
            $exporter->send_file(false));
134
            $exporter->send_file(false));
Línea 135... Línea 135...
135
 
135
 
Línea 136... Línea 136...
136
        $this->assertEquals(1, $exporter->get_records_count());
136
        $this->assertEquals(1, $exporter->get_records_count());
Línea 156... Línea 156...
156
            'files/picturefile.png' => 'mod/data/field/picture/pix/sample.png',
156
            'files/picturefile.png' => 'mod/data/field/picture/pix/sample.png',
157
            // By checking that the content of the exported csv is identical to the fixture file it is verified
157
            // By checking that the content of the exported csv is identical to the fixture file it is verified
158
            // that the filenames in the csv file correspond to the names of the exported file.
158
            // that the filenames in the csv file correspond to the names of the exported file.
159
            // It also verifies that files with identical file names in different fields (or records) will be numbered
159
            // It also verifies that files with identical file names in different fields (or records) will be numbered
160
            // automatically (samplefile.png, samplefile_1.png, ...).
160
            // automatically (samplefile.png, samplefile_1.png, ...).
161
            'testexportfile.csv' => __DIR__ . '/fixtures/test_data_export_with_files.csv'
161
            'testexportfile.csv' => self::get_fixture_path(__NAMESPACE__, 'test_data_export_with_files.csv'),
162
        ];
162
        ];
163
        for ($i = 0; $i < $ziparchive->count(); $i++) {
163
        for ($i = 0; $i < $ziparchive->count(); $i++) {
164
            // We here iterate over all files in the zip archive and check if their content is identical to the files
164
            // We here iterate over all files in the zip archive and check if their content is identical to the files
165
            // in the $expectedfilecontents array.
165
            // in the $expectedfilecontents array.
166
            $filestream = $ziparchive->get_stream($i);
166
            $filestream = $ziparchive->get_stream($i);