3 declare(strict_types=1);
25 require_once
"./Services/WebDAV/test/ilWebDAVTestHelper.php";
43 define(
'CLIENT_ID', $this->webdav_test_helper->getClientId());
44 define(
'ROOT_FOLDER_ID', 1);
52 "invalid_client_id/and_some_path" 56 foreach ($invalid_path as $current_path) {
58 $path_resolver->getRefIdForWebDAVPath($current_path);
59 $this->assertFalse(
'This should not happen!');
60 }
catch (BadRequest
$e) {
61 $this->assertEquals(
'Invalid client id given', $e->getMessage());
68 $path_only_clientid = $this->webdav_test_helper->getClientId();
71 $this->assertEquals(1, $path_resolver->getRefIdForWebDAVPath($path_only_clientid));
76 $path_with_valid_ref_id = $this->webdav_test_helper->getClientId() .
'/ref_50';
79 $this->assertEquals(50, $path_resolver->getRefIdForWebDAVPath($path_with_valid_ref_id));
84 $invalid_refmount_path = [
85 $this->webdav_test_helper->getClientId() .
'/ref_0',
86 $this->webdav_test_helper->getClientId() .
'/ref_-23',
87 $this->webdav_test_helper->getClientId() .
'/ref_adfadf' 91 foreach ($invalid_refmount_path as $current_path) {
93 $path_resolver->getRefIdForWebDAVPath($current_path);
94 $this->assertFalse(
'This should not happen!');
95 }
catch (NotFound
$e) {
96 $this->assertEquals(
'Mount point not found', $e->getMessage());
104 $path = $this->webdav_test_helper->getClientId() .
'/Last Child/Last Third Child';
105 $expected_ref_id = 2335634322;
108 $this->assertEquals($expected_ref_id, $path_resolver->getRefIdForWebDAVPath(
$path));
114 $path = $this->webdav_test_helper->getClientId() .
'/Second Child/Second First Child';
115 $expected_ref_id = 72;
118 $this->assertEquals($expected_ref_id, $path_resolver->getRefIdForWebDAVPath(
$path));
125 $this->webdav_test_helper->getClientId() .
'/Non exitent First Child/Last Third Child' => [
126 'parameters' => [1, 4],
127 'error_message' =>
'Node not found' 129 $this->webdav_test_helper->getClientId() .
'/Last Child/Non existent Last Child' => [
130 'parameters' => [2, 8],
131 'error_message' =>
'Last node not found' 135 foreach ($pathes as
$path => $additional_info) {
137 ...$additional_info[
'parameters']
140 $path_resolver->getRefIdForWebDAVPath(
$path);
141 $this->assertFalse(
'This should not happen!');
142 }
catch (NotFound
$e) {
143 $this->assertEquals($additional_info[
'error_message'], $e->getMessage());
150 $mocked_repo_helper = $this->createMock(ilWebDAVRepositoryHelper::class);
157 $tree = $webdav_test_helper->
getTree();
158 $mocked_repo_helper = $this->createMock(ilWebDAVRepositoryHelper::class);
159 $mocked_repo_helper->expects($this->exactly($expects_children))
160 ->method(
'getChildrenOfRefId')->willReturnCallback(
161 function (
int $parent_ref) use ($tree): array {
162 return $tree[$parent_ref][
'children'];
165 $mocked_repo_helper->expects($this->exactly($expects_ref_id))
166 ->method(
'getObjectTitleFromRefId')->willReturnCallback(
167 function (
int $ref_id) use ($tree):
string {
168 return $tree[
$ref_id][
'title'];
testGetRefIdForWebDAVPathWhenPathHasNoValidStartElementThrowsBadRequestError()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getPathResolverWithoutExpectationForFunctionsInHelper()
ilWebDAVTestHelper $webdav_test_helper
testGetRefIdForValidRefMountReturnsRefId()
__construct(?string $name=null, array $data=[], $dataName='')
testGetRefIdForWebDAVPathWithPathReturnsRefIdOfLastElement()
testGetRefIdForWebDAVPathWithPathPointingToElementWithIdenticalTitleReturnsRefIdOfLastIdenticalElement()
getPathResolverWithExpectationForFunctionsInHelper(int $expects_children, int $expects_ref_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
testGetRefIdForWebDAVPathWithInvalidPathThrowsNotFoundError()
__construct(Container $dic, ilPlugin $plugin)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
testGetRefIdForInvalidRefMountThrowsNotFoundError()
testGetRefIdForWebDAVWithValidClientIdReturnsRootFolderId()