Skip to content

Commit

Permalink
MDL-71470 repository_googledocs: Update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mihail Geshoski committed Apr 28, 2021
1 parent 0ce5195 commit 49ce037
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 25 deletions.
15 changes: 8 additions & 7 deletions repository/googledocs/tests/googledocs_search_content_test.php
Expand Up @@ -125,7 +125,7 @@ public function get_content_nodes_provider(): array {
'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'),
],
Expand All @@ -134,10 +134,11 @@ public function get_content_nodes_provider(): array {
"{$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'),
],
],
Expand Down Expand Up @@ -179,8 +180,8 @@ public function get_content_nodes_provider(): array {
],
[
$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.' =>
Expand Down
Expand Up @@ -120,18 +120,20 @@ public function get_content_nodes_provider(): array {
$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'),
],
[
$this->create_folder_content_node_array('0c4ad262c65333', 'Folder 1',
"{$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.' =>
Expand Down Expand Up @@ -171,10 +173,12 @@ public function get_content_nodes_provider(): array {
'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.' =>
Expand Down
15 changes: 8 additions & 7 deletions repository/googledocs/tests/local/node/file_node_test.php
Expand Up @@ -64,8 +64,9 @@ public function create_node_array_provider(): array {
$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.' =>
[
Expand All @@ -76,8 +77,8 @@ public function create_node_array_provider(): array {
[
'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.' =>
Expand All @@ -86,8 +87,8 @@ public function create_node_array_provider(): array {
'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).' =>
Expand All @@ -97,7 +98,7 @@ public function create_node_array_provider(): array {
[
'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'),
],
Expand Down
Expand Up @@ -54,19 +54,20 @@ protected function create_folder_content_node_array(string $id, string $name, st
*
* @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
* @param string|null $link The external link to the file
* @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,
Expand Down

0 comments on commit 49ce037

Please sign in to comment.