19 declare(strict_types=1);
    24 require_once 
"./Services/WebDAV/test/ilWebDAVTestHelper.php";
    42         define(
'CLIENT_ID', $this->webdav_test_helper->getClientId());
    43         define(
'ROOT_FOLDER_ID', 1);
    51             "invalid_client_id/and_some_path"    55         foreach ($invalid_path as $current_path) {
    57                 $path_resolver->getRefIdForWebDAVPath($current_path);
    58                 $this->assertFalse(
'This should not happen!');
    59             } 
catch (BadRequest 
$e) {
    60                 $this->assertEquals(
'Invalid client id given', $e->getMessage());
    67         $path_only_clientid = $this->webdav_test_helper->getClientId();
    70         $this->assertEquals(1, $path_resolver->getRefIdForWebDAVPath($path_only_clientid));
    75         $path_with_valid_ref_id = $this->webdav_test_helper->getClientId() . 
'/ref_50';
    78         $this->assertEquals(50, $path_resolver->getRefIdForWebDAVPath($path_with_valid_ref_id));
    83         $invalid_refmount_path = [
    84             $this->webdav_test_helper->getClientId() . 
'/ref_0',
    85             $this->webdav_test_helper->getClientId() . 
'/ref_-23',
    86             $this->webdav_test_helper->getClientId() . 
'/ref_adfadf'    90         foreach ($invalid_refmount_path as $current_path) {
    92                 $path_resolver->getRefIdForWebDAVPath($current_path);
    93                 $this->assertFalse(
'This should not happen!');
    94             } 
catch (NotFound 
$e) {
    95                 $this->assertEquals(
'Mount point not found', $e->getMessage());
   103         $path = $this->webdav_test_helper->getClientId() . 
'/Last Child/Last Third Child';
   104         $expected_ref_id = 2335634322;
   107         $this->assertEquals($expected_ref_id, $path_resolver->getRefIdForWebDAVPath(
$path));
   113         $path = $this->webdav_test_helper->getClientId() . 
'/Second Child/Second First Child';
   114         $expected_ref_id = 72;
   117         $this->assertEquals($expected_ref_id, $path_resolver->getRefIdForWebDAVPath(
$path));
   124             $this->webdav_test_helper->getClientId() . 
'/Non exitent First Child/Last Third Child' => [
   125                 'parameters' => [1, 4],
   126                 'error_message' => 
'Node not found'   128             $this->webdav_test_helper->getClientId() . 
'/Last Child/Non existent Last Child' => [
   129                 'parameters' => [2, 8],
   130                 'error_message' => 
'Last node not found'   134         foreach ($pathes as 
$path => $additional_info) {
   136                 ...$additional_info[
'parameters']
   139                 $path_resolver->getRefIdForWebDAVPath(
$path);
   140                 $this->assertFalse(
'This should not happen!');
   141             } 
catch (NotFound 
$e) {
   142                 $this->assertEquals($additional_info[
'error_message'], $e->getMessage());
   149         $mocked_repo_helper = $this->createMock(ilWebDAVRepositoryHelper::class);
   154         int $expects_children,
   158         $tree = $webdav_test_helper->
getTree();
   159         $mocked_repo_helper = $this->createMock(ilWebDAVRepositoryHelper::class);
   160         $mocked_repo_helper->expects($this->exactly($expects_children))
   161                            ->method(
'getChildrenOfRefId')->willReturnCallback(
   162                                fn(
int $parent_ref): array => $tree[$parent_ref][
'children']
   164         $mocked_repo_helper->expects($this->exactly($expects_ref_id))
   165                            ->method(
'getObjectTitleFromRefId')->willReturnCallback(
   166                                fn(
int $ref_id): 
string => $tree[$ref_id][
'title']
 testGetRefIdForWebDAVPathWhenPathHasNoValidStartElementThrowsBadRequestError()
 
getPathResolverWithoutExpectationForFunctionsInHelper()
 
ilWebDAVTestHelper $webdav_test_helper
 
testGetRefIdForValidRefMountReturnsRefId()
 
__construct(?string $name=null, array $data=[], $dataName='')
 
testGetRefIdForWebDAVPathWithPathReturnsRefIdOfLastElement()
 
testGetRefIdForWebDAVPathWithPathPointingToElementWithIdenticalTitleReturnsRefIdOfLastIdenticalElement()
 
getPathResolverWithExpectationForFunctionsInHelper(int $expects_children, int $expects_ref_id)
 
testGetRefIdForWebDAVPathWithInvalidPathThrowsNotFoundError()
 
testGetRefIdForInvalidRefMountThrowsNotFoundError()
 
testGetRefIdForWebDAVWithValidClientIdReturnsRootFolderId()