ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilWebDAVLockUriPathResolverTest Class Reference

disabled More...

+ Inheritance diagram for ilWebDAVLockUriPathResolverTest:
+ Collaboration diagram for ilWebDAVLockUriPathResolverTest:

Public Member Functions

 __construct (?string $name=null, array $data=[], $dataName='')
 
 setUp ()
 
 testGetRefIdForWebDAVPathWhenPathHasNoValidStartElementThrowsBadRequestError ()
 
 testGetRefIdForWebDAVWithValidClientIdReturnsRootFolderId ()
 
 testGetRefIdForValidRefMountReturnsRefId ()
 
 testGetRefIdForInvalidRefMountThrowsNotFoundError ()
 
 testGetRefIdForWebDAVPathWithPathReturnsRefIdOfLastElement ()
 
 testGetRefIdForWebDAVPathWithPathPointingToElementWithIdenticalTitleReturnsRefIdOfLastIdenticalElement ()
 
 testGetRefIdForWebDAVPathWithInvalidPathThrowsNotFoundError ()
 

Protected Member Functions

 getPathResolverWithoutExpectationForFunctionsInHelper ()
 
 getPathResolverWithExpectationForFunctionsInHelper (int $expects_children, int $expects_ref_id)
 

Protected Attributes

ilWebDAVTestHelper $webdav_test_helper
 

Detailed Description

disabled

Definition at line 30 of file ilWebDAVLockUriPathResolverTest.php.

Constructor & Destructor Documentation

◆ __construct()

ilWebDAVLockUriPathResolverTest::__construct ( ?string  $name = null,
array  $data = [],
  $dataName = '' 
)

Definition at line 34 of file ilWebDAVLockUriPathResolverTest.php.

References $data, and ILIAS\MetaData\Repository\Validation\Data\__construct().

35  {
36  $this->webdav_test_helper = new ilWebDAVTestHelper();
37  parent::__construct($name, $data, $dataName);
38  }
__construct(VocabulariesInterface $vocabularies)
+ Here is the call graph for this function:

Member Function Documentation

◆ getPathResolverWithExpectationForFunctionsInHelper()

ilWebDAVLockUriPathResolverTest::getPathResolverWithExpectationForFunctionsInHelper ( int  $expects_children,
int  $expects_ref_id 
)
protected

Definition at line 153 of file ilWebDAVLockUriPathResolverTest.php.

References $ref_id, and ilWebDAVTestHelper\getTree().

Referenced by testGetRefIdForWebDAVPathWithInvalidPathThrowsNotFoundError(), testGetRefIdForWebDAVPathWithPathPointingToElementWithIdenticalTitleReturnsRefIdOfLastIdenticalElement(), and testGetRefIdForWebDAVPathWithPathReturnsRefIdOfLastElement().

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']
163  );
164  $mocked_repo_helper->expects($this->exactly($expects_ref_id))
165  ->method('getObjectTitleFromRefId')->willReturnCallback(
166  fn(int $ref_id): string => $tree[$ref_id]['title']
167  );
168  return new ilWebDAVLockUriPathResolver($mocked_repo_helper);
169  }
$ref_id
Definition: ltiauth.php:67
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPathResolverWithoutExpectationForFunctionsInHelper()

ilWebDAVLockUriPathResolverTest::getPathResolverWithoutExpectationForFunctionsInHelper ( )
protected

◆ setUp()

ilWebDAVLockUriPathResolverTest::setUp ( )

Definition at line 40 of file ilWebDAVLockUriPathResolverTest.php.

40  : void
41  {
42  define('CLIENT_ID', $this->webdav_test_helper->getClientId());
43  define('ROOT_FOLDER_ID', 1);
44  }

◆ testGetRefIdForInvalidRefMountThrowsNotFoundError()

ilWebDAVLockUriPathResolverTest::testGetRefIdForInvalidRefMountThrowsNotFoundError ( )

Definition at line 81 of file ilWebDAVLockUriPathResolverTest.php.

References Vendor\Package\$e, and getPathResolverWithoutExpectationForFunctionsInHelper().

81  : void
82  {
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'
87  ];
89 
90  foreach ($invalid_refmount_path as $current_path) {
91  try {
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());
96  }
97  }
98  }
+ Here is the call graph for this function:

◆ testGetRefIdForValidRefMountReturnsRefId()

ilWebDAVLockUriPathResolverTest::testGetRefIdForValidRefMountReturnsRefId ( )

Definition at line 73 of file ilWebDAVLockUriPathResolverTest.php.

References getPathResolverWithoutExpectationForFunctionsInHelper().

73  : void
74  {
75  $path_with_valid_ref_id = $this->webdav_test_helper->getClientId() . '/ref_50';
77 
78  $this->assertEquals(50, $path_resolver->getRefIdForWebDAVPath($path_with_valid_ref_id));
79  }
+ Here is the call graph for this function:

◆ testGetRefIdForWebDAVPathWhenPathHasNoValidStartElementThrowsBadRequestError()

ilWebDAVLockUriPathResolverTest::testGetRefIdForWebDAVPathWhenPathHasNoValidStartElementThrowsBadRequestError ( )

Definition at line 46 of file ilWebDAVLockUriPathResolverTest.php.

References Vendor\Package\$e, and getPathResolverWithoutExpectationForFunctionsInHelper().

46  : void
47  {
48  $invalid_path = [
49  "",
50  "invalid_client_id",
51  "invalid_client_id/and_some_path"
52  ];
54 
55  foreach ($invalid_path as $current_path) {
56  try {
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());
61  }
62  }
63  }
+ Here is the call graph for this function:

◆ testGetRefIdForWebDAVPathWithInvalidPathThrowsNotFoundError()

ilWebDAVLockUriPathResolverTest::testGetRefIdForWebDAVPathWithInvalidPathThrowsNotFoundError ( )

Definition at line 120 of file ilWebDAVLockUriPathResolverTest.php.

References Vendor\Package\$e, $path, and getPathResolverWithExpectationForFunctionsInHelper().

120  : void
121  {
122  // Arrange
123  $pathes = [
124  $this->webdav_test_helper->getClientId() . '/Non exitent First Child/Last Third Child' => [
125  'parameters' => [1, 4],
126  'error_message' => 'Node not found'
127  ],
128  $this->webdav_test_helper->getClientId() . '/Last Child/Non existent Last Child' => [
129  'parameters' => [2, 8],
130  'error_message' => 'Last node not found'
131  ]
132  ];
133 
134  foreach ($pathes as $path => $additional_info) {
136  ...$additional_info['parameters']
137  );
138  try {
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());
143  }
144  }
145  }
$path
Definition: ltiservices.php:32
getPathResolverWithExpectationForFunctionsInHelper(int $expects_children, int $expects_ref_id)
+ Here is the call graph for this function:

◆ testGetRefIdForWebDAVPathWithPathPointingToElementWithIdenticalTitleReturnsRefIdOfLastIdenticalElement()

ilWebDAVLockUriPathResolverTest::testGetRefIdForWebDAVPathWithPathPointingToElementWithIdenticalTitleReturnsRefIdOfLastIdenticalElement ( )

Definition at line 110 of file ilWebDAVLockUriPathResolverTest.php.

References $path, and getPathResolverWithExpectationForFunctionsInHelper().

111  : void {
112  // Arrange
113  $path = $this->webdav_test_helper->getClientId() . '/Second Child/Second First Child';
114  $expected_ref_id = 72;
115  $path_resolver = $this->getPathResolverWithExpectationForFunctionsInHelper(2, 11);
116 
117  $this->assertEquals($expected_ref_id, $path_resolver->getRefIdForWebDAVPath($path));
118  }
$path
Definition: ltiservices.php:32
getPathResolverWithExpectationForFunctionsInHelper(int $expects_children, int $expects_ref_id)
+ Here is the call graph for this function:

◆ testGetRefIdForWebDAVPathWithPathReturnsRefIdOfLastElement()

ilWebDAVLockUriPathResolverTest::testGetRefIdForWebDAVPathWithPathReturnsRefIdOfLastElement ( )

Definition at line 100 of file ilWebDAVLockUriPathResolverTest.php.

References $path, and getPathResolverWithExpectationForFunctionsInHelper().

100  : void
101  {
102  // Arrange
103  $path = $this->webdav_test_helper->getClientId() . '/Last Child/Last Third Child';
104  $expected_ref_id = 2335634322;
105  $path_resolver = $this->getPathResolverWithExpectationForFunctionsInHelper(2, 8);
106 
107  $this->assertEquals($expected_ref_id, $path_resolver->getRefIdForWebDAVPath($path));
108  }
$path
Definition: ltiservices.php:32
getPathResolverWithExpectationForFunctionsInHelper(int $expects_children, int $expects_ref_id)
+ Here is the call graph for this function:

◆ testGetRefIdForWebDAVWithValidClientIdReturnsRootFolderId()

ilWebDAVLockUriPathResolverTest::testGetRefIdForWebDAVWithValidClientIdReturnsRootFolderId ( )

Definition at line 65 of file ilWebDAVLockUriPathResolverTest.php.

References getPathResolverWithoutExpectationForFunctionsInHelper().

65  : void
66  {
67  $path_only_clientid = $this->webdav_test_helper->getClientId();
69 
70  $this->assertEquals(1, $path_resolver->getRefIdForWebDAVPath($path_only_clientid));
71  }
+ Here is the call graph for this function:

Field Documentation

◆ $webdav_test_helper

ilWebDAVTestHelper ilWebDAVLockUriPathResolverTest::$webdav_test_helper
protected

Definition at line 32 of file ilWebDAVLockUriPathResolverTest.php.


The documentation for this class was generated from the following file: