Proyectos de Subversion Moodle

Rev

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

Rev 11 Rev 1441
Línea 35... Línea 35...
35
 *
35
 *
36
 * @copyright   2018 Andrew Nicols <andrew@nicols.co.uk>
36
 * @copyright   2018 Andrew Nicols <andrew@nicols.co.uk>
37
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
37
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
38
 * @coversDefaultClass \core_privacy\local\request\moodle_content_writer
38
 * @coversDefaultClass \core_privacy\local\request\moodle_content_writer
39
 */
39
 */
40
class moodle_content_writer_test extends advanced_testcase {
40
final class moodle_content_writer_test extends advanced_testcase {
Línea 41... Línea 41...
41
 
41
 
42
    /**
42
    /**
43
     * Test that exported data is saved correctly within the system context.
43
     * Test that exported data is saved correctly within the system context.
44
     *
44
     *
Línea 171... Línea 171...
171
    }
171
    }
Línea 172... Línea 172...
172
 
172
 
173
    /**
173
    /**
174
     * Data provider for exporting user data.
174
     * Data provider for exporting user data.
175
     */
175
     */
176
    public function export_data_provider() {
176
    public static function export_data_provider(): array {
177
        return [
177
        return [
178
            'basic' => [
178
            'basic' => [
179
                (object) [
179
                (object) [
180
                    'example' => (object) [
180
                    'example' => (object) [
Línea 306... Línea 306...
306
    /**
306
    /**
307
     * Data provider for exporting user metadata.
307
     * Data provider for exporting user metadata.
308
     *
308
     *
309
     * return   array
309
     * return   array
310
     */
310
     */
311
    public function export_metadata_provider() {
311
    public static function export_metadata_provider(): array {
312
        return [
312
        return [
313
            'basic' => [
313
            'basic' => [
314
                'key',
314
                'key',
315
                'value',
315
                'value',
316
                'This is a description',
316
                'This is a description',
Línea 470... Línea 470...
470
    /**
470
    /**
471
     * Data provider for the test_export_file function.
471
     * Data provider for the test_export_file function.
472
     *
472
     *
473
     * @return  array
473
     * @return  array
474
     */
474
     */
475
    public function export_file_provider() {
475
    public static function export_file_provider(): array {
476
        return [
476
        return [
477
            'basic' => [
477
            'basic' => [
478
                'intro',
478
                'intro',
479
                0,
479
                0,
480
                '/',
480
                '/',
Línea 505... Línea 505...
505
            'image' => [
505
            'image' => [
506
                'intro',
506
                'intro',
507
                0,
507
                0,
508
                '/',
508
                '/',
509
                'logo.png',
509
                'logo.png',
510
                file_get_contents(__DIR__ . '/fixtures/logo.png'),
510
                file_get_contents(self::get_fixture_path('core_privacy', 'logo.png')),
511
            ],
511
            ],
512
            'UTF8' => [
512
            'UTF8' => [
513
                'submission_content',
513
                'submission_content',
514
                2,
514
                2,
515
                '/Žluťoučký/',
515
                '/Žluťoučký/',
Línea 856... Línea 856...
856
    /**
856
    /**
857
     * Provider for various user preferences.
857
     * Provider for various user preferences.
858
     *
858
     *
859
     * @return  array
859
     * @return  array
860
     */
860
     */
861
    public function export_user_preference_provider() {
861
    public static function export_user_preference_provider(): array {
862
        return [
862
        return [
863
            'basic' => [
863
            'basic' => [
864
                'core_privacy',
864
                'core_privacy',
865
                'onekey',
865
                'onekey',
866
                'value',
866
                'value',
Línea 1022... Línea 1022...
1022
    /**
1022
    /**
1023
     * Provider for various user preferences.
1023
     * Provider for various user preferences.
1024
     *
1024
     *
1025
     * @return array
1025
     * @return array
1026
     */
1026
     */
1027
    public function unescaped_unicode_export_provider() {
1027
    public static function unescaped_unicode_export_provider(): array {
1028
        return [
1028
        return [
1029
            'Unicode' => ['ةكءيٓ‌پچژکگیٹڈڑہھےâîûğŞAaÇÖáǽ你好!'],
1029
            'Unicode' => ['ةكءيٓ‌پچژکگیٹڈڑہھےâîûğŞAaÇÖáǽ你好!'],
1030
        ];
1030
        ];
1031
    }
1031
    }
Línea 1191... Línea 1191...
1191
    /**
1191
    /**
1192
     * Provider for long filenames.
1192
     * Provider for long filenames.
1193
     *
1193
     *
1194
     * @return array
1194
     * @return array
1195
     */
1195
     */
1196
    public function long_filename_provider() {
1196
    public static function long_filename_provider(): array {
1197
        return [
1197
        return [
1198
            'More than 100 characters' => [
1198
            'More than 100 characters' => [
1199
                'Etiam sit amet dui vel leo blandit viverra. Proin viverra suscipit velit. Aenean efficitur suscipit nibh nec suscipit',
1199
                'Etiam sit amet dui vel leo blandit viverra. Proin viverra suscipit velit. Aenean efficitur suscipit nibh nec suscipit',
1200
                'Etiam sit amet dui vel leo blandit viverra. Proin viverra suscipit velit. Aenean effici - 22f7a5030d',
1200
                'Etiam sit amet dui vel leo blandit viverra. Proin viverra suscipit velit. Aenean effici - 22f7a5030d',
1201
                'value',
1201
                'value',
Línea 1286... Línea 1286...
1286
    /**
1286
    /**
1287
     * Provides testable sample data for {@link self::test_rewrite_pluginfile_urls()}.
1287
     * Provides testable sample data for {@link self::test_rewrite_pluginfile_urls()}.
1288
     *
1288
     *
1289
     * @return array
1289
     * @return array
1290
     */
1290
     */
1291
    public function rewrite_pluginfile_urls_provider() {
1291
    public static function rewrite_pluginfile_urls_provider(): array {
1292
        return [
1292
        return [
1293
            'nullcontent' => [
1293
            'nullcontent' => [
1294
                'intro',
1294
                'intro',
1295
                0,
1295
                0,
1296
                null,
1296
                null,
Línea 1340... Línea 1340...
1340
        $coursecategory = $this->getDataGenerator()->create_category();
1340
        $coursecategory = $this->getDataGenerator()->create_category();
1341
        $categorycontext = \context_coursecat::instance($coursecategory->id);
1341
        $categorycontext = \context_coursecat::instance($coursecategory->id);
1342
        $course = $this->getDataGenerator()->create_course();
1342
        $course = $this->getDataGenerator()->create_course();
1343
        $misccoursecxt = \context_coursecat::instance($course->category);
1343
        $misccoursecxt = \context_coursecat::instance($course->category);
1344
        $coursecontext = \context_course::instance($course->id);
1344
        $coursecontext = \context_course::instance($course->id);
1345
        $cm = $this->getDataGenerator()->create_module('chat', ['course' => $course->id]);
1345
        $cm = $this->getDataGenerator()->create_module('assign', ['course' => $course->id]);
1346
        $modulecontext = \context_module::instance($cm->cmid);
1346
        $modulecontext = \context_module::instance($cm->cmid);
Línea 1347... Línea 1347...
1347
 
1347
 
1348
        $writer->set_context($modulecontext)->export_data([], $data);
1348
        $writer->set_context($modulecontext)->export_data([], $data);
1349
        $writer->set_context($coursecontext)->export_data(['grades'], $data);
1349
        $writer->set_context($coursecontext)->export_data(['grades'], $data);
Línea 1380... Línea 1380...
1380
            'System _.1' => [
1380
            'System _.1' => [
1381
                'data.json',
1381
                'data.json',
1382
                'paper' => 'data.json',
1382
                'paper' => 'data.json',
1383
                'Category Category 1 _.' . $misccoursecxt->id => [
1383
                'Category Category 1 _.' . $misccoursecxt->id => [
1384
                    'Course Test course 1 _.' . $coursecontext->id => [
1384
                    'Course Test course 1 _.' . $coursecontext->id => [
1385
                        'Chat Chat 1 _.' . $modulecontext->id => 'data.json',
1385
                        'Assignment Assignment 1 _.' . $modulecontext->id => 'data.json',
1386
                        'grades' => 'data.json'
1386
                        'grades' => 'data.json'
1387
                    ]
1387
                    ]
1388
                ],
1388
                ],
1389
                'Category Course category 1 _.' . $categorycontext->id => 'data.json',
1389
                'Category Course category 1 _.' . $categorycontext->id => 'data.json',
1390
                '_files' => [
1390
                '_files' => [
Línea 1399... Línea 1399...
1399
 
1399
 
1400
        $expectedlistoutput = [
1400
        $expectedlistoutput = [
1401
            'System _.1/data.json' => 'data_file_1',
1401
            'System _.1/data.json' => 'data_file_1',
1402
            'System _.1/paper/data.json' => 'data_file_2',
1402
            'System _.1/paper/data.json' => 'data_file_2',
1403
            'System _.1/Category Category 1 _.' . $misccoursecxt->id . '/Course Test course 1 _.' .
1403
            'System _.1/Category Category 1 _.' . $misccoursecxt->id . '/Course Test course 1 _.' .
1404
                    $coursecontext->id . '/Chat Chat 1 _.' . $modulecontext->id . '/data.json'   => 'data_file_3',
1404
                    $coursecontext->id . '/Assignment Assignment 1 _.' . $modulecontext->id . '/data.json'   => 'data_file_3',
1405
            'System _.1/Category Category 1 _.' . $misccoursecxt->id . '/Course Test course 1 _.' .
1405
            'System _.1/Category Category 1 _.' . $misccoursecxt->id . '/Course Test course 1 _.' .
1406
                    $coursecontext->id . '/grades/data.json'   => 'data_file_4',
1406
                    $coursecontext->id . '/grades/data.json'   => 'data_file_4',
1407
            'System _.1/Category Course category 1 _.' . $categorycontext->id . '/data.json' => 'data_file_5',
1407
            'System _.1/Category Course category 1 _.' . $categorycontext->id . '/data.json' => 'data_file_5',
1408
            'System _.1/_files/tests/a.txt' => 'No var',
1408
            'System _.1/_files/tests/a.txt' => 'No var',
Línea 1412... Línea 1412...
1412
 
1412
 
1413
        $expectedindex = [
1413
        $expectedindex = [
1414
            'data_file_1' => 'System _.1/data.js',
1414
            'data_file_1' => 'System _.1/data.js',
1415
            'data_file_2' => 'System _.1/paper/data.js',
1415
            'data_file_2' => 'System _.1/paper/data.js',
1416
            'data_file_3' => 'System _.1/Category Category 1 _.' . $misccoursecxt->id . '/Course Test course 1 _.' .
1416
            'data_file_3' => 'System _.1/Category Category 1 _.' . $misccoursecxt->id . '/Course Test course 1 _.' .
1417
                    $coursecontext->id . '/Chat Chat 1 _.' . $modulecontext->id . '/data.js',
1417
                    $coursecontext->id . '/Assignment Assignment 1 _.' . $modulecontext->id . '/data.js',
1418
            'data_file_4' => 'System _.1/Category Category 1 _.' . $misccoursecxt->id . '/Course Test course 1 _.' .
1418
            'data_file_4' => 'System _.1/Category Category 1 _.' . $misccoursecxt->id . '/Course Test course 1 _.' .
1419
                    $coursecontext->id . '/grades/data.js',
1419
                    $coursecontext->id . '/grades/data.js',
1420
            'data_file_5' => 'System _.1/Category Course category 1 _.' . $categorycontext->id . '/data.js',
1420
            'data_file_5' => 'System _.1/Category Course category 1 _.' . $categorycontext->id . '/data.js',
1421
            'data_file_6' => 'System _.1/Logs/Standard log/data.js'
1421
            'data_file_6' => 'System _.1/Logs/Standard log/data.js'
Línea 1456... Línea 1456...
1456
                            'Course Test course 1 _.' . $coursecontext->id => (object) [
1456
                            'Course Test course 1 _.' . $coursecontext->id => (object) [
1457
                                'itemtype' => 'treeitem',
1457
                                'itemtype' => 'treeitem',
1458
                                'name' => 'Course Test course 1 ',
1458
                                'name' => 'Course Test course 1 ',
1459
                                'context' => $coursecontext,
1459
                                'context' => $coursecontext,
1460
                                'children' => [
1460
                                'children' => [
1461
                                    'Chat Chat 1 _.' . $modulecontext->id => (object) [
1461
                                    'Assignment Assignment 1 _.' . $modulecontext->id => (object) [
1462
                                        'itemtype' => 'treeitem',
1462
                                        'itemtype' => 'treeitem',
1463
                                        'name' => 'Chat Chat 1 ',
1463
                                        'name' => 'Assignment Assignment 1 ',
1464
                                        'context' => $modulecontext,
1464
                                        'context' => $modulecontext,
1465
                                        'children' => [
1465
                                        'children' => [
1466
                                            'data.json' => (object) [
1466
                                            'data.json' => (object) [
1467
                                                'name' => 'data.json',
1467
                                                'name' => 'data.json',
1468
                                                'itemtype' => 'item',
1468
                                                'itemtype' => 'item',
Línea 1560... Línea 1560...
1560
                            'Course Test course 1 _.' . $coursecontext->id => (object) [
1560
                            'Course Test course 1 _.' . $coursecontext->id => (object) [
1561
                                'itemtype' => 'treeitem',
1561
                                'itemtype' => 'treeitem',
1562
                                'name' => 'Course Test course 1 ',
1562
                                'name' => 'Course Test course 1 ',
1563
                                'context' => $coursecontext,
1563
                                'context' => $coursecontext,
1564
                                'children' => [
1564
                                'children' => [
1565
                                    'Chat Chat 1 _.' . $modulecontext->id => (object) [
1565
                                    'Assignment Assignment 1 _.' . $modulecontext->id => (object) [
1566
                                        'itemtype' => 'treeitem',
1566
                                        'itemtype' => 'treeitem',
1567
                                        'name' => 'Chat Chat 1 ',
1567
                                        'name' => 'Assignment Assignment 1 ',
1568
                                        'context' => $modulecontext,
1568
                                        'context' => $modulecontext,
1569
                                        'children' => [
1569
                                        'children' => [
1570
                                            'data.json' => (object) [
1570
                                            'data.json' => (object) [
1571
                                                'name' => 'data.json',
1571
                                                'name' => 'data.json',
1572
                                                'itemtype' => 'item',
1572
                                                'itemtype' => 'item',