mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-71470 repository_googledocs: Update unit tests
This commit is contained in:
parent
0ce519591b
commit
49ce037665
@ -125,7 +125,7 @@ class repository_googledocs_search_testcase extends \googledocs_content_testcase
|
||||
'application/pdf', 'pdf', '1000', '',
|
||||
'https://drive.google.com/uc?id=d85b21c0f86cb0&export=download'),
|
||||
$this->create_google_drive_folder_object('0c4ad262c65333', 'Test folder 1'),
|
||||
$this->create_google_drive_file_object('bed5a0f08d412a', 'Test file 1',
|
||||
$this->create_google_drive_file_object('bed5a0f08d412a', 'Test file 1.pdf',
|
||||
'application/pdf', 'pdf'),
|
||||
$this->create_google_drive_folder_object('9c4ad262c65333', 'Test folder 2'),
|
||||
],
|
||||
@ -134,10 +134,11 @@ class repository_googledocs_search_testcase extends \googledocs_content_testcase
|
||||
"{$rootid}|Google+Drive/{$searchnodeid}|" . urlencode("{$searchforstring} 'test'")),
|
||||
$this->create_folder_content_node_array('9c4ad262c65333', 'Test folder 2',
|
||||
"{$rootid}|Google+Drive/{$searchnodeid}|" . urlencode("{$searchforstring} 'test'")),
|
||||
$this->create_file_content_node_array('bed5a0f08d412a', 'Test file 1', null,
|
||||
'', 'https://googleusercontent.com/type/application/pdf', '', 'download'),
|
||||
$this->create_file_content_node_array('d85b21c0f86cb0', 'Test file 3.pdf', '1000',
|
||||
'', 'https://googleusercontent.com/type/application/pdf',
|
||||
$this->create_file_content_node_array('bed5a0f08d412a', 'Test file 1.pdf',
|
||||
'Test file 1.pdf', null, '', 'https://googleusercontent.com/type/application/pdf',
|
||||
'', 'download'),
|
||||
$this->create_file_content_node_array('d85b21c0f86cb0', 'Test file 3.pdf',
|
||||
'Test file 3.pdf', '1000', '', 'https://googleusercontent.com/type/application/pdf',
|
||||
'https://drive.google.com/uc?id=d85b21c0f86cb0&export=download', 'download'),
|
||||
],
|
||||
],
|
||||
@ -179,8 +180,8 @@ class repository_googledocs_search_testcase extends \googledocs_content_testcase
|
||||
],
|
||||
[
|
||||
$this->create_file_content_node_array('d85b21c0f86cb0', 'Testing file 3.pdf',
|
||||
'1000', '', 'https://googleusercontent.com/type/application/pdf',
|
||||
'', 'download'),
|
||||
'Testing file 3.pdf', '1000', '',
|
||||
'https://googleusercontent.com/type/application/pdf', '', 'download'),
|
||||
],
|
||||
],
|
||||
'No content that matches the search criteria; shared drives do not exist.' =>
|
||||
|
@ -120,7 +120,7 @@ class repository_googledocs_drive_browser_testcase extends \googledocs_content_t
|
||||
$this->create_google_drive_file_object('d85b21c0f86cb0', 'File 3.pdf',
|
||||
'application/pdf', 'pdf', '1000'),
|
||||
$this->create_google_drive_folder_object('0c4ad262c65333', 'Folder 1'),
|
||||
$this->create_google_drive_file_object('bed5a0f08d412a', 'File 1',
|
||||
$this->create_google_drive_file_object('bed5a0f08d412a', 'File 1.pdf',
|
||||
'application/pdf', 'pdf'),
|
||||
],
|
||||
[
|
||||
@ -128,10 +128,12 @@ class repository_googledocs_drive_browser_testcase extends \googledocs_content_t
|
||||
"{$rootid}|Google+Drive/{$mydriveid}|My+Drive"),
|
||||
$this->create_folder_content_node_array('1c4ad262c65333', 'Folder 2',
|
||||
"{$rootid}|Google+Drive/{$mydriveid}|My+Drive"),
|
||||
$this->create_file_content_node_array('bed5a0f08d412a', 'File 1', null, '',
|
||||
'https://googleusercontent.com/type/application/pdf', '', 'download'),
|
||||
$this->create_file_content_node_array('d85b21c0f86cb0', 'File 3.pdf', '1000', '',
|
||||
'https://googleusercontent.com/type/application/pdf', '', 'download'),
|
||||
$this->create_file_content_node_array('bed5a0f08d412a', 'File 1.pdf', 'File 1.pdf',
|
||||
null, '', 'https://googleusercontent.com/type/application/pdf', '',
|
||||
'download'),
|
||||
$this->create_file_content_node_array('d85b21c0f86cb0', 'File 3.pdf', 'File 3.pdf',
|
||||
'1000', '', 'https://googleusercontent.com/type/application/pdf', '',
|
||||
'download'),
|
||||
],
|
||||
],
|
||||
'Only folders exist in the drive; shared drives do not exist; ordering not applied.' =>
|
||||
@ -171,10 +173,12 @@ class repository_googledocs_drive_browser_testcase extends \googledocs_content_t
|
||||
'application/msword', 'doc', '2000'),
|
||||
],
|
||||
[
|
||||
$this->create_file_content_node_array('d85b21c0f86cb0', 'File 3.pdf', '1000', '',
|
||||
'https://googleusercontent.com/type/application/pdf', '', 'download'),
|
||||
$this->create_file_content_node_array('f85b21c0f86cb0', 'File 2.doc', '2000', '',
|
||||
'https://googleusercontent.com/type/application/msword', '', 'download'),
|
||||
$this->create_file_content_node_array('d85b21c0f86cb0', 'File 3.pdf', 'File 3.pdf',
|
||||
'1000', '', 'https://googleusercontent.com/type/application/pdf', '',
|
||||
'download'),
|
||||
$this->create_file_content_node_array('f85b21c0f86cb0', 'File 2.doc', 'File 2.doc',
|
||||
'2000', '', 'https://googleusercontent.com/type/application/msword', '',
|
||||
'download'),
|
||||
],
|
||||
],
|
||||
'Contents do not exist in the drive; shared drives do not exist.' =>
|
||||
|
@ -64,8 +64,9 @@ class file_node_testcase extends \repository_googledocs_testcase {
|
||||
$this->create_google_drive_file_object('d85b21c0f86cb0', 'File.pdf',
|
||||
'application/pdf', 'pdf', '1000', '01/01/21 0:30'),
|
||||
[],
|
||||
$this->create_file_content_node_array('d85b21c0f86cb0', 'File.pdf', '1000', '1609432200',
|
||||
'https://googleusercontent.com/type/application/pdf', '', 'download'),
|
||||
$this->create_file_content_node_array('d85b21c0f86cb0', 'File.pdf', 'File.pdf', '1000',
|
||||
'1609432200', 'https://googleusercontent.com/type/application/pdf', '',
|
||||
'download'),
|
||||
],
|
||||
'Google Drive file that has webContentLink and webViewLink.' =>
|
||||
[
|
||||
@ -76,8 +77,8 @@ class file_node_testcase extends \repository_googledocs_testcase {
|
||||
[
|
||||
'documentformat' => 'rtf',
|
||||
],
|
||||
$this->create_file_content_node_array('d85b21c0f86cb0', 'File.pdf', null, '',
|
||||
'https://googleusercontent.com/type/application/pdf',
|
||||
$this->create_file_content_node_array('d85b21c0f86cb0', 'File.pdf', 'File.pdf', null,
|
||||
'', 'https://googleusercontent.com/type/application/pdf',
|
||||
'https://drive.google.com/file/d/d85b21c0f86cb0/view?usp=drivesdk', 'download'),
|
||||
],
|
||||
'Google Drive file that has webContentLink and no webViewLink.' =>
|
||||
@ -86,8 +87,8 @@ class file_node_testcase extends \repository_googledocs_testcase {
|
||||
'application/pdf', 'pdf', null, '',
|
||||
'https://drive.google.com/uc?id=d85b21c0f86cb0&export=download', ''),
|
||||
[],
|
||||
$this->create_file_content_node_array('d85b21c0f86cb0', 'File.pdf', null, '',
|
||||
'https://googleusercontent.com/type/application/pdf',
|
||||
$this->create_file_content_node_array('d85b21c0f86cb0', 'File.pdf', 'File.pdf', null,
|
||||
'', 'https://googleusercontent.com/type/application/pdf',
|
||||
'https://drive.google.com/uc?id=d85b21c0f86cb0&export=download', 'download'),
|
||||
],
|
||||
'Google Drive file without an extension (Google document file; documentformat config set to rtf).' =>
|
||||
@ -97,7 +98,7 @@ class file_node_testcase extends \repository_googledocs_testcase {
|
||||
[
|
||||
'documentformat' => 'rtf',
|
||||
],
|
||||
$this->create_file_content_node_array('d85b21c0f86cb0', 'File.gdoc', '', '',
|
||||
$this->create_file_content_node_array('d85b21c0f86cb0', 'File', 'File.gdoc', '', '',
|
||||
'https://googleusercontent.com/type/application/vnd.google-apps.document', '',
|
||||
'application/rtf'),
|
||||
],
|
||||
|
@ -54,6 +54,7 @@ abstract class repository_googledocs_testcase extends \advanced_testcase {
|
||||
*
|
||||
* @param string $id The ID of the file
|
||||
* @param string $name The name of the file
|
||||
* @param string $title The title of the file node
|
||||
* @param string|null $size The size of the file
|
||||
* @param string $modified The date of the last modification
|
||||
* @param string $thumbnail The thumbnail of the file
|
||||
@ -61,12 +62,12 @@ abstract class repository_googledocs_testcase extends \advanced_testcase {
|
||||
* @param string|null $exportformat The export format of the file
|
||||
* @return array The repository file node array
|
||||
*/
|
||||
protected function create_file_content_node_array(string $id, string $name, ?string $size = null,
|
||||
protected function create_file_content_node_array(string $id, string $name, string $title, ?string $size = null,
|
||||
string $modified = '', string $thumbnail = '' , string $link = '', string $exportformat = ''): array {
|
||||
|
||||
return [
|
||||
'id' => $id,
|
||||
'title' => $name,
|
||||
'title' => $title,
|
||||
'source' => json_encode([
|
||||
'id' => $id,
|
||||
'name' => $name,
|
||||
|
Loading…
x
Reference in New Issue
Block a user