Proyectos de Subversion Moodle

Rev

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

Rev 11 Rev 1441
Línea 26... Línea 26...
26
 *
26
 *
27
 * @package    repository_googledocs
27
 * @package    repository_googledocs
28
 * @copyright  2021 Mihail Geshoski <mihail@moodle.com>
28
 * @copyright  2021 Mihail Geshoski <mihail@moodle.com>
29
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
29
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
30
 */
30
 */
31
class file_node_test extends \repository_googledocs_testcase {
31
final class file_node_test extends \repository_googledocs_testcase {
32
 
-
 
33
    /**
32
    /**
34
     * Test create_node_array().
33
     * Test create_node_array().
35
     *
34
     *
36
     * @dataProvider create_node_array_provider
35
     * @dataProvider create_node_array_provider
37
     * @param \stdClass $gdfile The Google Drive file object
36
     * @param \stdClass $gdfile The Google Drive file object
Línea 54... Línea 53...
54
    /**
53
    /**
55
     * Data provider for test_create_node_array().
54
     * Data provider for test_create_node_array().
56
     *
55
     *
57
     * @return array
56
     * @return array
58
     */
57
     */
59
    public function create_node_array_provider(): array {
58
    public static function create_node_array_provider(): array {
60
 
-
 
61
        return [
59
        return [
62
            'Google Drive file with an extension.' =>
60
            'Google Drive file with an extension.' =>
63
                [
61
                [
64
                    $this->create_google_drive_file_object('d85b21c0f86cb0', 'File.pdf',
62
                    self::create_google_drive_file_object('d85b21c0f86cb0', 'File.pdf',
65
                        'application/pdf', 'pdf', '1000', '01/01/21 0:30'),
63
                        'application/pdf', 'pdf', '1000', '01/01/21 0:30'),
66
                    [],
64
                    [],
67
                    $this->create_file_content_node_array('d85b21c0f86cb0', 'File.pdf', 'File.pdf', '1000',
65
                    self::create_file_content_node_array('d85b21c0f86cb0', 'File.pdf', 'File.pdf', '1000',
68
                        '1609432200', 'https://googleusercontent.com/type/application/pdf', '',
66
                        '1609432200', 'https://googleusercontent.com/type/application/pdf', '',
69
                        'download'),
67
                        'download'),
70
                ],
68
                ],
71
            'Google Drive file that has webContentLink and webViewLink.' =>
69
            'Google Drive file that has webContentLink and webViewLink.' =>
72
                [
70
                [
73
                    $this->create_google_drive_file_object('d85b21c0f86cb0', 'File.pdf',
71
                    self::create_google_drive_file_object('d85b21c0f86cb0', 'File.pdf',
74
                        'application/pdf', 'pdf', null, '',
72
                        'application/pdf', 'pdf', null, '',
75
                        'https://drive.google.com/uc?id=d85b21c0f86cb0&export=download',
73
                        'https://drive.google.com/uc?id=d85b21c0f86cb0&export=download',
76
                        'https://drive.google.com/file/d/d85b21c0f86cb0/view?usp=drivesdk'),
74
                        'https://drive.google.com/file/d/d85b21c0f86cb0/view?usp=drivesdk'),
77
                    [
75
                    [
78
                        'documentformat' => 'rtf',
76
                        'documentformat' => 'rtf',
79
                    ],
77
                    ],
80
                    $this->create_file_content_node_array('d85b21c0f86cb0', 'File.pdf', 'File.pdf', null,
78
                    self::create_file_content_node_array('d85b21c0f86cb0', 'File.pdf', 'File.pdf', null,
81
                        '', 'https://googleusercontent.com/type/application/pdf',
79
                        '', 'https://googleusercontent.com/type/application/pdf',
82
                        'https://drive.google.com/file/d/d85b21c0f86cb0/view?usp=drivesdk', 'download'),
80
                        'https://drive.google.com/file/d/d85b21c0f86cb0/view?usp=drivesdk', 'download'),
83
                ],
81
                ],
84
            'Google Drive file that has webContentLink and no webViewLink.' =>
82
            'Google Drive file that has webContentLink and no webViewLink.' =>
85
                [
83
                [
86
                    $this->create_google_drive_file_object('d85b21c0f86cb0', 'File.pdf',
84
                    self::create_google_drive_file_object('d85b21c0f86cb0', 'File.pdf',
87
                        'application/pdf', 'pdf', null, '',
85
                        'application/pdf', 'pdf', null, '',
88
                        'https://drive.google.com/uc?id=d85b21c0f86cb0&export=download', ''),
86
                        'https://drive.google.com/uc?id=d85b21c0f86cb0&export=download', ''),
89
                    [],
87
                    [],
90
                    $this->create_file_content_node_array('d85b21c0f86cb0', 'File.pdf', 'File.pdf', null,
88
                    self::create_file_content_node_array('d85b21c0f86cb0', 'File.pdf', 'File.pdf', null,
91
                        '', 'https://googleusercontent.com/type/application/pdf',
89
                        '', 'https://googleusercontent.com/type/application/pdf',
92
                        'https://drive.google.com/uc?id=d85b21c0f86cb0&export=download', 'download'),
90
                        'https://drive.google.com/uc?id=d85b21c0f86cb0&export=download', 'download'),
93
                ],
91
                ],
94
            'Google Drive file without an extension (Google document file; documentformat config set to rtf).' =>
92
            'Google Drive file without an extension (Google document file; documentformat config set to rtf).' =>
95
                [
93
                [
96
                    $this->create_google_drive_file_object('d85b21c0f86cb0', 'File',
94
                    self::create_google_drive_file_object('d85b21c0f86cb0', 'File',
97
                        'application/vnd.google-apps.document', null),
95
                        'application/vnd.google-apps.document', null),
98
                    [
96
                    [
99
                        'documentformat' => 'rtf',
97
                        'documentformat' => 'rtf',
100
                    ],
98
                    ],
101
                    $this->create_file_content_node_array('d85b21c0f86cb0', 'File', 'File.gdoc', '', '',
99
                    self::create_file_content_node_array('d85b21c0f86cb0', 'File', 'File.gdoc', '', '',
102
                        'https://googleusercontent.com/type/application/vnd.google-apps.document', '',
100
                        'https://googleusercontent.com/type/application/vnd.google-apps.document', '',
103
                        'application/rtf', 'document'),
101
                        'application/rtf', 'document'),
104
                ],
102
                ],
105
            'Google Drive file without an extension (Google presentation file; presentationformat config not set).' =>
103
            'Google Drive file without an extension (Google presentation file; presentationformat config not set).' =>
106
                [
104
                [
107
                    $this->create_google_drive_file_object('d85b21c0f86cb0', 'File',
105
                    self::create_google_drive_file_object('d85b21c0f86cb0', 'File',
108
                        'application/vnd.google-apps.presentation', null),
106
                        'application/vnd.google-apps.presentation', null),
109
                    [
107
                    [
110
                        'documentformat' => 'rtf',
108
                        'documentformat' => 'rtf',
111
                    ],
109
                    ],
112
                    null,
110
                    null,
113
                ],
111
                ],
114
            'Google Drive file without an extension (File type not supported).' =>
112
            'Google Drive file without an extension (File type not supported).' =>
115
                [
113
                [
116
                    $this->create_google_drive_file_object('d85b21c0f86cb0', 'File',
114
                    self::create_google_drive_file_object('d85b21c0f86cb0', 'File',
117
                        'application/vnd.google-apps.unknownmimetype', null),
115
                        'application/vnd.google-apps.unknownmimetype', null),
118
                    [],
116
                    [],
119
                    null,
117
                    null,
120
                ],
118
                ],
121
        ];
119
        ];