Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 310 and 311] [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403] [Versions 39 and 310]

This file contains tests for the repository_nextcloud class.

Copyright: 2017 Project seminar (Learnweb, University of Münster)
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 633 lines (28 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: repository_nextcloud_access_controlled_link_manager_testcase  - X-Ref

Class repository_nextcloud_testcase

setUp()   X-Ref
SetUp to create an repository instance.


test_create_share_user_sysaccount_user_shares()   X-Ref
Function to test the private function create_share_user_sysaccount.


test_delete_share_dataowner_sysaccount()   X-Ref
Test the delete_share_function. In case the request fails, the function throws an exception, however this
can not be tested in phpUnit since it is javascript.


test_create_folder_path_folders_are_not_created()   X-Ref
Function which test that create folder path does return the adequate results (path and success).
Additionally mock checks whether the right params are passed to the corresponding functions.


test_create_folder_path_folders_are_created()   X-Ref
Function which test that create folder path does return the adequate results (path and success).
Additionally mock checks whether the right params are passed to the corresponding functions.


test_create_folder_path_folder_creation_fails()   X-Ref
Test whether the create_folder_path methode throws exception.


set_up_mocks_for_create_folder_path($returnisdir, $returnestedcontext, $callmkcol = false,$returnmkcol = 201)   X-Ref
Helper function to generate mocks for testing create folder path.

param: bool $returnisdir Return value mocking the result of invoking is_dir
param: bool $returnestedcontext Name of the folder that is simulated to be checked/created
param: bool $callmkcol Also mock creation of the folder
param: int $returnmkcol Return value mocking the result of invoking mkcol
return: array ['mockcontext' context_module mock, 'mockclient' => webdav client mock]

test_create_storage_folder_success()   X-Ref
Test whether the right methods from the webdavclient are called when the storage_folder is created.
1. Directory already exist -> no further action needed.


test_create_storage_folder_success_mkcol()   X-Ref
Test whether the right methods from the webdavclient are called when the storage_folder is created.
2. Directory does not exist. It is created with mkcol and returns a success.


test_create_storage_folder_failure()   X-Ref
Test whether the right methods from the webdavclient are called when the storage_folder is created.
3. Request to create Folder fails.


test_transfer_file_to_path_copyfile()   X-Ref
Test whether the webdav client gets the right params and whether function differentiates between move and copy.


test_transfer_file_to_path_copyfile_movefile()   X-Ref
This function tests whether the function transfer_file_to_path() moves or copies a given file to a given path
It tests whether the webdav_client gets the right parameter and whether function distinguishes between move and copy.


test_get_shares_from_path()   X-Ref
Test the get_shares_from path() function. This function extracts from an list of shares the share of a given user
(the username is a parameter in the function call) and returns the id. The test firstly test whether the right fileid
for user1 is extracted then for user2 and last but least whether an error is thrown if the user does not have a share.


test_create_system_dav()   X-Ref
No description

test_get_share_information_from_shareid()   X-Ref
Tests the function get_share_information_from_shareid(). From a response with two element it is tested
whether the right file_target is extracted and lastly it is checked whether an error is thrown in case no suitable
element exists.


set_private_property($value, $propertyname, $class)   X-Ref
Helper method which inserts a value into a non-public field of an object.

param: mixed $value mock value that will be inserted.
param: string $propertyname name of the private property.
param: object $class Instance that is being modified.
return: ReflectionProperty the resulting reflection property.

get_private_property($propertyname, $class)   X-Ref
Helper method which gets a value from a non-public field of an object.

param: string $propertyname name of the private property.
param: object $class Instance that is being modified.
return: mixed the resulting value.

delete_endpoints($endpointname)   X-Ref
Deletes all endpoint with the given name.

param: string $endpointname
return: array|null