mirror of
https://github.com/moodle/moodle.git
synced 2025-03-25 01:50:55 +01:00
Merge branch 'MDL69756_master' of https://github.com/Amrita1991/moodle
This commit is contained in:
commit
ce691018db
@ -207,7 +207,7 @@ class access_controlled_link_manager{
|
||||
}
|
||||
}
|
||||
$this->systemwebdavclient->close();
|
||||
if (!($result == 201 || $result == 412)) {
|
||||
if (!($result == 201 || $result == 204 || $result == 412)) {
|
||||
$details = get_string('contactadminwith', 'repository_nextcloud',
|
||||
'A webdav request to ' . $operation . ' a file failed.');
|
||||
throw new request_exception(array('instance' => $this->repositoryname, 'errormessage' => $details));
|
||||
|
@ -306,6 +306,30 @@ XML;
|
||||
|
||||
$this->assertEquals(201, $result);
|
||||
}
|
||||
/**
|
||||
* Test whether the webdav client gets the right params and whether function handles overwrite.
|
||||
*
|
||||
* @covers \repository_nextcloud\access_controlled_link_manager::transfer_file_to_path
|
||||
*/
|
||||
public function test_transfer_file_to_path_overwritefile() {
|
||||
// Initialize params.
|
||||
$parsedwebdavurl = parse_url($this->issuer->get_endpoint_url('webdav'));
|
||||
$webdavprefix = $parsedwebdavurl['path'];
|
||||
$srcpath = 'sourcepath';
|
||||
$dstpath = "destinationpath/another/path";
|
||||
|
||||
// Mock the Webdavclient and set expected methods.
|
||||
$systemwebdavclientmock = $this->createMock(\webdav_client::class);
|
||||
$systemwebdavclientmock->expects($this->once())->method('open')->willReturn(true);
|
||||
$systemwebdavclientmock->expects($this->once())->method('copy_file')->with($webdavprefix . $srcpath,
|
||||
$webdavprefix . $dstpath . '/' . $srcpath, true)->willReturn(204);
|
||||
$this->set_private_property($systemwebdavclientmock, 'systemwebdavclient', $this->linkmanager);
|
||||
|
||||
// Call of function.
|
||||
$result = $this->linkmanager->transfer_file_to_path($srcpath, $dstpath, 'copy');
|
||||
|
||||
$this->assertEquals(204, $result);
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user