Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 1441
Línea 102... Línea 102...
102
            'data' => $data,
102
            'data' => $data,
103
            'cm' => $cm,
103
            'cm' => $cm,
104
            'teacher' => $teacher,
104
            'teacher' => $teacher,
105
        ] = $this->get_test_data();
105
        ] = $this->get_test_data();
Línea 106... Línea 106...
106
 
106
 
107
        $importer = new csv_entries_importer(__DIR__ . '/fixtures/test_data_import.csv',
107
        $importer = new csv_entries_importer(self::get_fixture_path(__NAMESPACE__, 'test_data_import.csv'),
108
            'test_data_import.csv');
108
            'test_data_import.csv');
Línea 109... Línea 109...
109
        $importer->import_csv($cm, $data, 'UTF-8', 'comma');
109
        $importer->import_csv($cm, $data, 'UTF-8', 'comma');
110
 
110
 
Línea 134... Línea 134...
134
            'cm' => $cm,
134
            'cm' => $cm,
135
            'teacher' => $teacher,
135
            'teacher' => $teacher,
136
            'student' => $student,
136
            'student' => $student,
137
        ] = $this->get_test_data();
137
        ] = $this->get_test_data();
Línea 138... Línea 138...
138
 
138
 
139
        $importer = new csv_entries_importer(__DIR__ . '/fixtures/test_data_import_with_userdata.csv',
139
        $importer = new csv_entries_importer(self::get_fixture_path(__NAMESPACE__, 'test_data_import_with_userdata.csv'),
140
            'test_data_import_with_userdata.csv');
140
            'test_data_import_with_userdata.csv');
Línea 141... Línea 141...
141
        $importer->import_csv($cm, $data, 'UTF-8', 'comma');
141
        $importer->import_csv($cm, $data, 'UTF-8', 'comma');
142
 
142
 
Línea 175... Línea 175...
175
        $fieldrecord = new \stdClass();
175
        $fieldrecord = new \stdClass();
176
        $fieldrecord->name = 'Username';
176
        $fieldrecord->name = 'Username';
177
        $fieldrecord->type = 'text';
177
        $fieldrecord->type = 'text';
178
        $generator->create_field($fieldrecord, $data);
178
        $generator->create_field($fieldrecord, $data);
Línea 179... Línea 179...
179
 
179
 
180
        $importer = new csv_entries_importer(__DIR__ . '/fixtures/test_data_import_with_field_username.csv',
180
        $importer = new csv_entries_importer(self::get_fixture_path(__NAMESPACE__, 'test_data_import_with_field_username.csv'),
181
            'test_data_import_with_field_username.csv');
181
            'test_data_import_with_field_username.csv');
Línea 182... Línea 182...
182
        $importer->import_csv($cm, $data, 'UTF-8', 'comma');
182
        $importer->import_csv($cm, $data, 'UTF-8', 'comma');
183
 
183
 
Línea 237... Línea 237...
237
        $fieldrecord = new \stdClass();
237
        $fieldrecord = new \stdClass();
238
        $fieldrecord->name = 'Username';
238
        $fieldrecord->name = 'Username';
239
        $fieldrecord->type = 'text';
239
        $fieldrecord->type = 'text';
240
        $generator->create_field($fieldrecord, $data);
240
        $generator->create_field($fieldrecord, $data);
Línea 241... Línea 241...
241
 
241
 
242
        $importer = new csv_entries_importer(__DIR__ . '/fixtures/test_data_import_with_userdata.csv',
242
        $importer = new csv_entries_importer(self::get_fixture_path(__NAMESPACE__, 'test_data_import_with_userdata.csv'),
243
            'test_data_import_with_userdata.csv');
243
            'test_data_import_with_userdata.csv');
Línea 244... Línea 244...
244
        $importer->import_csv($cm, $data, 'UTF-8', 'comma');
244
        $importer->import_csv($cm, $data, 'UTF-8', 'comma');
245
 
245
 
Línea 296... Línea 296...
296
        $testdata = $this->get_test_data();
296
        $testdata = $this->get_test_data();
297
        ['data' => $data, 'cm' => $cm] = $testdata;
297
        ['data' => $data, 'cm' => $cm] = $testdata;
Línea 298... Línea 298...
298
 
298
 
Línea 299... Línea 299...
299
        $this->setUser($testdata[$user]);
299
        $this->setUser($testdata[$user]);
300
 
300
 
Línea 301... Línea 301...
301
        $importer = new csv_entries_importer(__DIR__ . '/fixtures/test_data_import.csv', 'test_data_import.csv');
301
        $importer = new csv_entries_importer(self::get_fixture_path(__NAMESPACE__, 'test_data_import.csv'), 'test_data_import.csv');
302
        $importer->import_csv($cm, $data, 'UTF-8', 'comma');
302
        $importer->import_csv($cm, $data, 'UTF-8', 'comma');
303
 
303
 
Línea 329... Línea 329...
329
        $testdata = $this->get_test_data();
329
        $testdata = $this->get_test_data();
330
        ['data' => $data, 'cm' => $cm] = $testdata;
330
        ['data' => $data, 'cm' => $cm] = $testdata;
Línea 331... Línea 331...
331
 
331
 
Línea 332... Línea 332...
332
        $this->setUser($testdata[$user]);
332
        $this->setUser($testdata[$user]);
333
 
333
 
334
        $importer = new csv_entries_importer(__DIR__ . '/fixtures/test_data_import_with_approved.csv',
334
        $importer = new csv_entries_importer(self::get_fixture_path(__NAMESPACE__, 'test_data_import_with_approved.csv'),
Línea 335... Línea 335...
335
            'test_data_import_with_approved.csv');
335
            'test_data_import_with_approved.csv');
336
        $importer->import_csv($cm, $data, 'UTF-8', 'comma');
336
        $importer->import_csv($cm, $data, 'UTF-8', 'comma');
Línea 346... Línea 346...
346
        [
346
        [
347
            'data' => $data,
347
            'data' => $data,
348
            'cm' => $cm,
348
            'cm' => $cm,
349
        ] = $this->get_test_data();
349
        ] = $this->get_test_data();
Línea 350... Línea 350...
350
 
350
 
351
        $importer = new csv_entries_importer(__DIR__ . '/fixtures/test_data_import_with_files.zip',
351
        $importer = new csv_entries_importer(self::get_fixture_path(__NAMESPACE__, 'test_data_import_with_files.zip'),
352
            'test_data_import_with_files.zip');
352
            'test_data_import_with_files.zip');
Línea 353... Línea 353...
353
        $importer->import_csv($cm, $data, 'UTF-8', 'comma');
353
        $importer->import_csv($cm, $data, 'UTF-8', 'comma');
354
 
354
 
355
        $records = $this->get_data_records($data->id);
355
        $records = $this->get_data_records($data->id);
Línea 356... Línea 356...
356
        $ziparchive = new zip_archive();
356
        $ziparchive = new zip_archive();
357
        $ziparchive->open(__DIR__ . '/fixtures/test_data_import_with_files.zip');
357
        $ziparchive->open(self::get_fixture_path(__NAMESPACE__, 'test_data_import_with_files.zip'));
358
 
358
 
359
        $importedcontent = array_values($records)[0]->items;
359
        $importedcontent = array_values($records)[0]->items;
Línea 393... Línea 393...
393
        [
393
        [
394
            'data' => $data,
394
            'data' => $data,
395
            'cm' => $cm,
395
            'cm' => $cm,
396
        ] = $this->get_test_data();
396
        ] = $this->get_test_data();
Línea 397... Línea 397...
397
 
397
 
398
        $importer = new csv_entries_importer(__DIR__ . '/fixtures/test_data_import_with_files_missing_file.zip',
398
        $importer = new csv_entries_importer(self::get_fixture_path(__NAMESPACE__, 'test_data_import_with_files_missing_file.zip'),
399
            'test_data_import_with_files_missing_file.zip');
399
            'test_data_import_with_files_missing_file.zip');
Línea 400... Línea 400...
400
        $importer->import_csv($cm, $data, 'UTF-8', 'comma');
400
        $importer->import_csv($cm, $data, 'UTF-8', 'comma');
401
 
401
 
402
        $records = $this->get_data_records($data->id);
402
        $records = $this->get_data_records($data->id);
Línea 403... Línea 403...
403
        $ziparchive = new zip_archive();
403
        $ziparchive = new zip_archive();
404
        $ziparchive->open(__DIR__ . '/fixtures/test_data_import_with_files_missing_file.zip');
404
        $ziparchive->open(self::get_fixture_path(__NAMESPACE__, 'test_data_import_with_files_missing_file.zip'));
405
 
405
 
406
        $importedcontent = array_values($records)[0]->items;
406
        $importedcontent = array_values($records)[0]->items;
Línea 461... Línea 461...
461
    /**
461
    /**
462
     * Data provider method for self::test_get_added_record_messages.
462
     * Data provider method for self::test_get_added_record_messages.
463
     *
463
     *
464
     * @return array data for testing
464
     * @return array data for testing
465
     */
465
     */
466
    public function get_added_record_messages_provider(): array {
466
    public static function get_added_record_messages_provider(): array {
467
        return [
467
        return [
468
            'only header' => [
468
            'only header' => [
469
                'datafilecontent' => 'ID,Param2,filefield,picturefield' . PHP_EOL,
469
                'datafilecontent' => 'ID,Param2,filefield,picturefield' . PHP_EOL,
470
                'expectedcount' => 0 // One line is being assumed to be the header.
470
                'expectedcount' => 0 // One line is being assumed to be the header.
471
            ],
471
            ],