19 declare(strict_types=1);
25 #[\PHPUnit\Framework\Attributes\PreserveGlobalState(false)] 26 #[\PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses] 39 define(
'CLIENT_ID', $this->webdav_test_helper->getClientId());
40 define(
'ROOT_FOLDER_ID', 1);
48 "invalid_client_id/and_some_path" 52 foreach ($invalid_path as $current_path) {
54 $path_resolver->getRefIdForWebDAVPath($current_path);
55 $this->assertFalse(
'This should not happen!');
56 }
catch (BadRequest
$e) {
57 $this->assertEquals(
'Invalid client id given', $e->getMessage());
64 $path_only_clientid = $this->webdav_test_helper->getClientId();
67 $this->assertEquals(1, $path_resolver->getRefIdForWebDAVPath($path_only_clientid));
72 $path_with_valid_ref_id = $this->webdav_test_helper->getClientId() .
'/ref_50';
75 $this->assertEquals(50, $path_resolver->getRefIdForWebDAVPath($path_with_valid_ref_id));
80 $invalid_refmount_path = [
81 $this->webdav_test_helper->getClientId() .
'/ref_0',
82 $this->webdav_test_helper->getClientId() .
'/ref_-23',
83 $this->webdav_test_helper->getClientId() .
'/ref_adfadf' 87 foreach ($invalid_refmount_path as $current_path) {
89 $path_resolver->getRefIdForWebDAVPath($current_path);
90 $this->assertFalse(
'This should not happen!');
91 }
catch (NotFound
$e) {
92 $this->assertEquals(
'Mount point not found', $e->getMessage());
100 $path = $this->webdav_test_helper->getClientId() .
'/Last Child/Last Third Child';
101 $expected_ref_id = 2335634322;
104 $this->assertEquals($expected_ref_id, $path_resolver->getRefIdForWebDAVPath(
$path));
110 $path = $this->webdav_test_helper->getClientId() .
'/Second Child/Second First Child';
111 $expected_ref_id = 72;
114 $this->assertEquals($expected_ref_id, $path_resolver->getRefIdForWebDAVPath(
$path));
121 $this->webdav_test_helper->getClientId() .
'/Non exitent First Child/Last Third Child' => [
122 'parameters' => [1, 4],
123 'error_message' =>
'Node not found' 125 $this->webdav_test_helper->getClientId() .
'/Last Child/Non existent Last Child' => [
126 'parameters' => [2, 8],
127 'error_message' =>
'Last node not found' 131 foreach ($pathes as
$path => $additional_info) {
133 ...$additional_info[
'parameters']
136 $path_resolver->getRefIdForWebDAVPath(
$path);
137 $this->assertFalse(
'This should not happen!');
138 }
catch (NotFound
$e) {
139 $this->assertEquals($additional_info[
'error_message'], $e->getMessage());
146 $mocked_repo_helper = $this->createMock(ilWebDAVRepositoryHelper::class);
151 int $expects_children,
155 $tree = $webdav_test_helper->
getTree();
156 $mocked_repo_helper = $this->createMock(ilWebDAVRepositoryHelper::class);
157 $mocked_repo_helper->expects($this->exactly($expects_children))
158 ->method(
'getChildrenOfRefId')->willReturnCallback(
159 fn(
int $parent_ref): array => $tree[$parent_ref][
'children']
161 $mocked_repo_helper->expects($this->exactly($expects_ref_id))
162 ->method(
'getObjectTitleFromRefId')->willReturnCallback(
163 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()