| Línea 27... | 
            Línea 27... | 
          
          
            | 27 | 
             *
  | 
            27 | 
             *
  | 
          
          
            | 28 | 
             * @package    repository_googledocs
  | 
            28 | 
             * @package    repository_googledocs
  | 
          
          
            | 29 | 
             * @copyright  2021 Mihail Geshoski <mihail@moodle.com>
  | 
            29 | 
             * @copyright  2021 Mihail Geshoski <mihail@moodle.com>
  | 
          
          
            | 30 | 
             * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  | 
            30 | 
             * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  | 
          
          
            | 31 | 
             */
  | 
            31 | 
             */
  | 
          
          
            | 32 | 
            class googledocs_search_content_test extends \googledocs_content_testcase {
  | 
            32 | 
            final class googledocs_search_content_test extends \googledocs_content_testcase {
  | 
          
          
            | Línea 33... | 
            Línea 33... | 
          
          
            | 33 | 
             
  | 
            33 | 
             
  | 
          
          
            | 34 | 
                /**
  | 
            34 | 
                /**
  | 
          
          
            | 35 | 
                 * Test get_content_nodes().
  | 
            35 | 
                 * Test get_content_nodes().
  | 
          
          
            | 36 | 
                 *
  | 
            36 | 
                 *
  | 
          
          
            | Línea 62... | 
            Línea 62... | 
          
          
            | 62 | 
             
  | 
            62 | 
             
  | 
          
          
            | 63 | 
                    // Assert that the call() method is being called twice with the given arguments consecutively. In the first
  | 
            63 | 
                    // Assert that the call() method is being called twice with the given arguments consecutively. In the first
  | 
          
          
            | 64 | 
                    // instance it is being called to fetch the shared drives (shared_drives_list), while in the second instance
  | 
            64 | 
                    // instance it is being called to fetch the shared drives (shared_drives_list), while in the second instance
  | 
          
          
            | 65 | 
                    // to fetch the relevant drive contents (list) that match the search criteria. Also, define the returned
  | 
            65 | 
                    // to fetch the relevant drive contents (list) that match the search criteria. Also, define the returned
  | 
          
          
            | - | 
               | 
            66 | 
                    // data objects by these calls.
  | 
          
          
            | 66 | 
                    // data objects by these calls.
  | 
            67 | 
                    $callinvocations = $this->exactly(2);
  | 
          
          
            | 67 | 
                    $servicemock->expects($this->exactly(2))
  | 
            68 | 
                    $servicemock->expects($callinvocations)
  | 
          
          
            | 68 | 
                        ->method('call')
  | 
            69 | 
                        ->method('call')
  | 
          
          
            | 69 | 
                        ->withConsecutive(
  | 
            70 | 
                        ->willReturnCallback(function(string $method, array $params) use (
  | 
          
          
            | 70 | 
                            [
  | 
            71 | 
                            $callinvocations,
  | 
          
          
            | 71 | 
                                'shared_drives_list',
  | 
            72 | 
                            $shareddrives,
  | 
          
          
            | 72 | 
                                [],
  | 
            73 | 
                            $searccontents,
  | 
          
          
            | 73 | 
                            ],
  | 
            74 | 
                            $searchparams,
  | 
          
          
            | 74 | 
                            [
  | 
            75 | 
                        ) {
  | 
          
          
            | 75 | 
                                'list',
  | 
            76 | 
                            switch (self::getInvocationCount($callinvocations)) {
  | 
          
          
            | 76 | 
                                $searchparams,
  | 
            77 | 
                                case 1:
  | 
          
          
            | 77 | 
                            ]
  | 
            78 | 
                                    $this->assertEquals('shared_drives_list', $method);
  | 
          
          
            | 78 | 
                        )
  | 
            79 | 
             
  | 
          
          
            | 79 | 
                        ->willReturnOnConsecutiveCalls(
  | 
            80 | 
                                    $this->assertEmpty($params);
  | 
          
          
            | 80 | 
                            (object)[
  | 
            81 | 
                                    return (object) [
  | 
          
          
            | 81 | 
                                'kind' => 'drive#driveList',
  | 
            82 | 
                                        'kind' => 'drive#driveList',
  | 
          
          
            | 82 | 
                                'nextPageToken' => 'd838181f30b0f5',
  | 
            83 | 
                                        'nextPageToken' => 'd838181f30b0f5',
  | 
          
          
            | 83 | 
                                'drives' => $shareddrives,
  | 
            84 | 
                                        'drives' => $shareddrives,
  | 
          
          
            | 84 | 
                            ],
  | 
            85 | 
                                    ];
  | 
          
          
            | - | 
               | 
            86 | 
                                case 2:
  | 
          
          
            | - | 
               | 
            87 | 
                                    $this->assertEquals('list', $method);
  | 
          
          
            | - | 
               | 
            88 | 
                                    $this->assertEquals($searchparams, $params);
  | 
          
          
            | - | 
               | 
            89 | 
             
  | 
          
          
            | 85 | 
                            (object)[
  | 
            90 | 
                                    return (object) [
  | 
          
          
            | - | 
               | 
            91 | 
                                        'files' => $searccontents,
  | 
          
          
            | 86 | 
                                'files' => $searccontents,
  | 
            92 | 
                                    ];
  | 
          
          
            | 87 | 
                            ]
  | 
            93 | 
                            }
  | 
          
          
            | Línea 88... | 
            Línea 94... | 
          
          
            | 88 | 
                        );
  | 
            94 | 
                        });
  | 
          
          
            | 89 | 
             
  | 
            95 | 
             
  | 
          
          
            | 90 | 
                    // Construct the node path.
  | 
            96 | 
                    // Construct the node path.
  | 
          
          
            | 91 | 
                    $path = \repository_googledocs::REPOSITORY_ROOT_ID . '|' . urlencode('Google Drive') . '/' .
  | 
            97 | 
                    $path = \repository_googledocs::REPOSITORY_ROOT_ID . '|' . urlencode('Google Drive') . '/' .
  | 
          
          
            | Línea 103... | 
            Línea 109... | 
          
          
            | 103 | 
                /**
  | 
            109 | 
                /**
  | 
          
          
            | 104 | 
                 * Data provider for test_get_content_nodes().
  | 
            110 | 
                 * Data provider for test_get_content_nodes().
  | 
          
          
            | 105 | 
                 *
  | 
            111 | 
                 *
  | 
          
          
            | 106 | 
                 * @return array
  | 
            112 | 
                 * @return array
  | 
          
          
            | 107 | 
                 */
  | 
            113 | 
                 */
  | 
          
          
            | 108 | 
                public function get_content_nodes_provider(): array {
  | 
            114 | 
                public static function get_content_nodes_provider(): array {
  | 
          
          
            | Línea 109... | 
            Línea 115... | 
          
          
            | 109 | 
             
  | 
            115 | 
             
  | 
          
          
            | 110 | 
                    $rootid = \repository_googledocs::REPOSITORY_ROOT_ID;
  | 
            116 | 
                    $rootid = \repository_googledocs::REPOSITORY_ROOT_ID;
  | 
          
          
            | 111 | 
                    $searchnodeid = \repository_googledocs::SEARCH_ROOT_ID;
  | 
            117 | 
                    $searchnodeid = \repository_googledocs::SEARCH_ROOT_ID;
  | 
          
          
            | Línea 116... | 
            Línea 122... | 
          
          
            | 116 | 
                            [
  | 
            122 | 
                            [
  | 
          
          
            | 117 | 
                                'test',
  | 
            123 | 
                                'test',
  | 
          
          
            | 118 | 
                                true,
  | 
            124 | 
                                true,
  | 
          
          
            | 119 | 
                                [],
  | 
            125 | 
                                [],
  | 
          
          
            | 120 | 
                                [
  | 
            126 | 
                                [
  | 
          
          
            | 121 | 
                                    $this->create_google_drive_shared_drive_object('d85b21c0f86cb5', 'Shared Drive 1'),
  | 
            127 | 
                                    self::create_google_drive_shared_drive_object('d85b21c0f86cb5', 'Shared Drive 1'),
  | 
          
          
            | 122 | 
                                ],
  | 
            128 | 
                                ],
  | 
          
          
            | 123 | 
                                [
  | 
            129 | 
                                [
  | 
          
          
            | 124 | 
                                    $this->create_google_drive_file_object('d85b21c0f86cb0', 'Test file 3.pdf',
  | 
            130 | 
                                    self::create_google_drive_file_object('d85b21c0f86cb0', 'Test file 3.pdf',
  | 
          
          
            | 125 | 
                                        'application/pdf', 'pdf', '1000', '',
  | 
            131 | 
                                        'application/pdf', 'pdf', '1000', '',
  | 
          
          
            | 126 | 
                                        'https://drive.google.com/uc?id=d85b21c0f86cb0&export=download'),
  | 
            132 | 
                                        'https://drive.google.com/uc?id=d85b21c0f86cb0&export=download'),
  | 
          
          
            | 127 | 
                                    $this->create_google_drive_folder_object('0c4ad262c65333', 'Test folder 1'),
  | 
            133 | 
                                    self::create_google_drive_folder_object('0c4ad262c65333', 'Test folder 1'),
  | 
          
          
            | 128 | 
                                    $this->create_google_drive_file_object('bed5a0f08d412a', 'Test file 1.pdf',
  | 
            134 | 
                                    self::create_google_drive_file_object('bed5a0f08d412a', 'Test file 1.pdf',
  | 
          
          
            | 129 | 
                                        'application/pdf', 'pdf'),
  | 
            135 | 
                                        'application/pdf', 'pdf'),
  | 
          
          
            | 130 | 
                                    $this->create_google_drive_folder_object('9c4ad262c65333', 'Test folder 2'),
  | 
            136 | 
                                    self::create_google_drive_folder_object('9c4ad262c65333', 'Test folder 2'),
  | 
          
          
            | 131 | 
                                ],
  | 
            137 | 
                                ],
  | 
          
          
            | 132 | 
                                [
  | 
            138 | 
                                [
  | 
          
          
            | 133 | 
                                    $this->create_folder_content_node_array('0c4ad262c65333', 'Test folder 1',
  | 
            139 | 
                                    self::create_folder_content_node_array('0c4ad262c65333', 'Test folder 1',
  | 
          
          
            | 134 | 
                                        "{$rootid}|Google+Drive/{$searchnodeid}|" . urlencode("{$searchforstring} 'test'")),
  | 
            140 | 
                                        "{$rootid}|Google+Drive/{$searchnodeid}|" . urlencode("{$searchforstring} 'test'")),
  | 
          
          
            | 135 | 
                                    $this->create_folder_content_node_array('9c4ad262c65333', 'Test folder 2',
  | 
            141 | 
                                    self::create_folder_content_node_array('9c4ad262c65333', 'Test folder 2',
  | 
          
          
            | 136 | 
                                        "{$rootid}|Google+Drive/{$searchnodeid}|" . urlencode("{$searchforstring} 'test'")),
  | 
            142 | 
                                        "{$rootid}|Google+Drive/{$searchnodeid}|" . urlencode("{$searchforstring} 'test'")),
  | 
          
          
            | 137 | 
                                    $this->create_file_content_node_array('bed5a0f08d412a', 'Test file 1.pdf',
  | 
            143 | 
                                    self::create_file_content_node_array('bed5a0f08d412a', 'Test file 1.pdf',
  | 
          
          
            | 138 | 
                                        'Test file 1.pdf', null, '', 'https://googleusercontent.com/type/application/pdf',
  | 
            144 | 
                                        'Test file 1.pdf', null, '', 'https://googleusercontent.com/type/application/pdf',
  | 
          
          
            | 139 | 
                                        '', 'download'),
  | 
            145 | 
                                        '', 'download'),
  | 
          
          
            | 140 | 
                                    $this->create_file_content_node_array('d85b21c0f86cb0', 'Test file 3.pdf',
  | 
            146 | 
                                    self::create_file_content_node_array('d85b21c0f86cb0', 'Test file 3.pdf',
  | 
          
          
            | 141 | 
                                        'Test file 3.pdf', '1000', '', 'https://googleusercontent.com/type/application/pdf',
  | 
            147 | 
                                        'Test file 3.pdf', '1000', '', 'https://googleusercontent.com/type/application/pdf',
  | 
          
          
            | 142 | 
                                        'https://drive.google.com/uc?id=d85b21c0f86cb0&export=download', 'download'),
  | 
            148 | 
                                        'https://drive.google.com/uc?id=d85b21c0f86cb0&export=download', 'download'),
  | 
          
          
            | 143 | 
                                ],
  | 
            149 | 
                                ],
  | 
          
          
            | 144 | 
                            ],
  | 
            150 | 
                            ],
  | 
          
          
            | 145 | 
                        'Only folders match the search criteria; shared drives do not exist; ordering not applied.' =>
  | 
            151 | 
                        'Only folders match the search criteria; shared drives do not exist; ordering not applied.' =>
  | 
          
          
            | Línea 147... | 
            Línea 153... | 
          
          
            | 147 | 
                                'testing',
  | 
            153 | 
                                'testing',
  | 
          
          
            | 148 | 
                                false,
  | 
            154 | 
                                false,
  | 
          
          
            | 149 | 
                                [],
  | 
            155 | 
                                [],
  | 
          
          
            | 150 | 
                                [],
  | 
            156 | 
                                [],
  | 
          
          
            | 151 | 
                                [
  | 
            157 | 
                                [
  | 
          
          
            | 152 | 
                                    $this->create_google_drive_folder_object('0c4ad262c65333', 'Testing folder 3'),
  | 
            158 | 
                                    self::create_google_drive_folder_object('0c4ad262c65333', 'Testing folder 3'),
  | 
          
          
            | 153 | 
                                    $this->create_google_drive_folder_object('d85b21c0f86cb0', 'Testing folder 1'),
  | 
            159 | 
                                    self::create_google_drive_folder_object('d85b21c0f86cb0', 'Testing folder 1'),
  | 
          
          
            | 154 | 
                                    $this->create_google_drive_folder_object('bed5a0f08d412a', 'Testing folder 2'),
  | 
            160 | 
                                    self::create_google_drive_folder_object('bed5a0f08d412a', 'Testing folder 2'),
  | 
          
          
            | 155 | 
                                ],
  | 
            161 | 
                                ],
  | 
          
          
            | 156 | 
                                [
  | 
            162 | 
                                [
  | 
          
          
            | 157 | 
                                    $this->create_folder_content_node_array('0c4ad262c65333', 'Testing folder 3',
  | 
            163 | 
                                    self::create_folder_content_node_array('0c4ad262c65333', 'Testing folder 3',
  | 
          
          
            | 158 | 
                                        "{$rootid}|Google+Drive/{$searchnodeid}|" . urlencode("{$searchforstring} 'testing'")),
  | 
            164 | 
                                        "{$rootid}|Google+Drive/{$searchnodeid}|" . urlencode("{$searchforstring} 'testing'")),
  | 
          
          
            | 159 | 
                                    $this->create_folder_content_node_array('d85b21c0f86cb0', 'Testing folder 1',
  | 
            165 | 
                                    self::create_folder_content_node_array('d85b21c0f86cb0', 'Testing folder 1',
  | 
          
          
            | 160 | 
                                        "{$rootid}|Google+Drive/{$searchnodeid}|" . urlencode("{$searchforstring} 'testing'")),
  | 
            166 | 
                                        "{$rootid}|Google+Drive/{$searchnodeid}|" . urlencode("{$searchforstring} 'testing'")),
  | 
          
          
            | 161 | 
                                    $this->create_folder_content_node_array('bed5a0f08d412a', 'Testing folder 2',
  | 
            167 | 
                                    self::create_folder_content_node_array('bed5a0f08d412a', 'Testing folder 2',
  | 
          
          
            | 162 | 
                                        "{$rootid}|Google+Drive/{$searchnodeid}|" . urlencode("{$searchforstring} 'testing'")),
  | 
            168 | 
                                        "{$rootid}|Google+Drive/{$searchnodeid}|" . urlencode("{$searchforstring} 'testing'")),
  | 
          
          
            | 163 | 
                                ],
  | 
            169 | 
                                ],
  | 
          
          
            | 164 | 
                            ],
  | 
            170 | 
                            ],
  | 
          
          
            | 165 | 
                        'Only files match the search criteria; shared drives exist; ordering not applied; filter .doc and .txt.' =>
  | 
            171 | 
                        'Only files match the search criteria; shared drives exist; ordering not applied; filter .doc and .txt.' =>
  | 
          
          
            | 166 | 
                            [
  | 
            172 | 
                            [
  | 
          
          
            | 167 | 
                                'root',
  | 
            173 | 
                                'root',
  | 
          
          
            | 168 | 
                                false,
  | 
            174 | 
                                false,
  | 
          
          
            | 169 | 
                                ['doc', 'txt'],
  | 
            175 | 
                                ['doc', 'txt'],
  | 
          
          
            | 170 | 
                                [
  | 
            176 | 
                                [
  | 
          
          
            | 171 | 
                                    $this->create_google_drive_shared_drive_object('d85b21c0f86cb5', 'Shared Drive 1'),
  | 
            177 | 
                                    self::create_google_drive_shared_drive_object('d85b21c0f86cb5', 'Shared Drive 1'),
  | 
          
          
            | 172 | 
                                ],
  | 
            178 | 
                                ],
  | 
          
          
            | 173 | 
                                [
  | 
            179 | 
                                [
  | 
          
          
            | 174 | 
                                    $this->create_google_drive_file_object('d85b21c0f86cb0', 'Testing file 3.pdf',
  | 
            180 | 
                                    self::create_google_drive_file_object('d85b21c0f86cb0', 'Testing file 3.pdf',
  | 
          
          
            | 175 | 
                                        'application/pdf', 'pdf', '1000'),
  | 
            181 | 
                                        'application/pdf', 'pdf', '1000'),
  | 
          
          
            | 176 | 
                                    $this->create_google_drive_file_object('a85b21c0f86cb0', 'Testing file 1.txt',
  | 
            182 | 
                                    self::create_google_drive_file_object('a85b21c0f86cb0', 'Testing file 1.txt',
  | 
          
          
            | 177 | 
                                        'text/plain', 'txt', '3000'),
  | 
            183 | 
                                        'text/plain', 'txt', '3000'),
  | 
          
          
            | 178 | 
                                    $this->create_google_drive_file_object('f85b21c0f86cb0', 'Testing file 2.doc',
  | 
            184 | 
                                    self::create_google_drive_file_object('f85b21c0f86cb0', 'Testing file 2.doc',
  | 
          
          
            | 179 | 
                                        'application/msword', 'doc', '2000'),
  | 
            185 | 
                                        'application/msword', 'doc', '2000'),
  | 
          
          
            | 180 | 
                                ],
  | 
            186 | 
                                ],
  | 
          
          
            | 181 | 
                                [
  | 
            187 | 
                                [
  | 
          
          
            | 182 | 
                                    $this->create_file_content_node_array('d85b21c0f86cb0', 'Testing file 3.pdf',
  | 
            188 | 
                                    self::create_file_content_node_array('d85b21c0f86cb0', 'Testing file 3.pdf',
  | 
          
          
            | 183 | 
                                        'Testing file 3.pdf', '1000', '',
  | 
            189 | 
                                        'Testing file 3.pdf', '1000', '',
  | 
          
          
            | 184 | 
                                        'https://googleusercontent.com/type/application/pdf', '', 'download'),
  | 
            190 | 
                                        'https://googleusercontent.com/type/application/pdf', '', 'download'),
  | 
          
          
            | 185 | 
                                ],
  | 
            191 | 
                                ],
  | 
          
          
            | 186 | 
                            ],
  | 
            192 | 
                            ],
  | 
          
          
            | 187 | 
                        'No content that matches the search criteria; shared drives do not exist.' =>
  | 
            193 | 
                        'No content that matches the search criteria; shared drives do not exist.' =>
  |