19 declare(strict_types=1);
41 define(
'CLIENT_ID', $this->webdav_test_helper->getClientId());
42 define(
'ROOT_FOLDER_ID', 1);
50 "invalid_client_id/and_some_path" 54 foreach ($invalid_path as $current_path) {
56 $path_resolver->getRefIdForWebDAVPath($current_path);
57 $this->assertFalse(
'This should not happen!');
58 }
catch (BadRequest
$e) {
59 $this->assertEquals(
'Invalid client id given', $e->getMessage());
66 $path_only_clientid = $this->webdav_test_helper->getClientId();
69 $this->assertEquals(1, $path_resolver->getRefIdForWebDAVPath($path_only_clientid));
74 $path_with_valid_ref_id = $this->webdav_test_helper->getClientId() .
'/ref_50';
77 $this->assertEquals(50, $path_resolver->getRefIdForWebDAVPath($path_with_valid_ref_id));
82 $invalid_refmount_path = [
83 $this->webdav_test_helper->getClientId() .
'/ref_0',
84 $this->webdav_test_helper->getClientId() .
'/ref_-23',
85 $this->webdav_test_helper->getClientId() .
'/ref_adfadf' 89 foreach ($invalid_refmount_path as $current_path) {
91 $path_resolver->getRefIdForWebDAVPath($current_path);
92 $this->assertFalse(
'This should not happen!');
93 }
catch (NotFound
$e) {
94 $this->assertEquals(
'Mount point not found', $e->getMessage());
102 $path = $this->webdav_test_helper->getClientId() .
'/Last Child/Last Third Child';
103 $expected_ref_id = 2335634322;
106 $this->assertEquals($expected_ref_id, $path_resolver->getRefIdForWebDAVPath(
$path));
112 $path = $this->webdav_test_helper->getClientId() .
'/Second Child/Second First Child';
113 $expected_ref_id = 72;
116 $this->assertEquals($expected_ref_id, $path_resolver->getRefIdForWebDAVPath(
$path));
123 $this->webdav_test_helper->getClientId() .
'/Non exitent First Child/Last Third Child' => [
124 'parameters' => [1, 4],
125 'error_message' =>
'Node not found' 127 $this->webdav_test_helper->getClientId() .
'/Last Child/Non existent Last Child' => [
128 'parameters' => [2, 8],
129 'error_message' =>
'Last node not found' 133 foreach ($pathes as
$path => $additional_info) {
135 ...$additional_info[
'parameters']
138 $path_resolver->getRefIdForWebDAVPath(
$path);
139 $this->assertFalse(
'This should not happen!');
140 }
catch (NotFound
$e) {
141 $this->assertEquals($additional_info[
'error_message'], $e->getMessage());
148 $mocked_repo_helper = $this->createMock(ilWebDAVRepositoryHelper::class);
153 int $expects_children,
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 fn(
int $parent_ref): array => $tree[$parent_ref][
'children']
163 $mocked_repo_helper->expects($this->exactly($expects_ref_id))
164 ->method(
'getObjectTitleFromRefId')->willReturnCallback(
165 fn(
int $ref_id):
string => $tree[$ref_id][
'title']
testGetRefIdForWebDAVPathWhenPathHasNoValidStartElementThrowsBadRequestError()
getPathResolverWithoutExpectationForFunctionsInHelper()
ilWebDAVTestHelper $webdav_test_helper
testGetRefIdForValidRefMountReturnsRefId()
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
__construct(?string $name=null, array $data=[], $dataName='')
testGetRefIdForWebDAVPathWithPathReturnsRefIdOfLastElement()
testGetRefIdForWebDAVPathWithPathPointingToElementWithIdenticalTitleReturnsRefIdOfLastIdenticalElement()
getPathResolverWithExpectationForFunctionsInHelper(int $expects_children, int $expects_ref_id)
testGetRefIdForWebDAVPathWithInvalidPathThrowsNotFoundError()
__construct(Container $dic, ilPlugin $plugin)
testGetRefIdForInvalidRefMountThrowsNotFoundError()
testGetRefIdForWebDAVWithValidClientIdReturnsRootFolderId()