ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilWebDAVLockUriPathResolverTest Class Reference
+ Inheritance diagram for ilWebDAVLockUriPathResolverTest:
+ Collaboration diagram for ilWebDAVLockUriPathResolverTest:

Public Member Functions

 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

Definition at line 27 of file ilWebDAVLockUriPathResolverTest.php.

Member Function Documentation

◆ getPathResolverWithExpectationForFunctionsInHelper()

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

Definition at line 145 of file ilWebDAVLockUriPathResolverTest.php.

150 $tree = $webdav_test_helper->getTree();
151 $mocked_repo_helper = $this->createMock(ilWebDAVRepositoryHelper::class);
152 $mocked_repo_helper->expects($this->exactly($expects_children))
153 ->method('getChildrenOfRefId')->willReturnCallback(
154 fn(int $parent_ref): array => $tree[$parent_ref]['children']
155 );
156 $mocked_repo_helper->expects($this->exactly($expects_ref_id))
157 ->method('getObjectTitleFromRefId')->willReturnCallback(
158 fn(int $ref_id): string => $tree[$ref_id]['title']
159 );
160 return new ilWebDAVLockUriPathResolver($mocked_repo_helper);
161 }
$ref_id
Definition: ltiauth.php:66

Referenced by testGetRefIdForWebDAVPathWithPathReturnsRefIdOfLastElement().

+ Here is the caller graph for this function:

◆ getPathResolverWithoutExpectationForFunctionsInHelper()

ilWebDAVLockUriPathResolverTest::getPathResolverWithoutExpectationForFunctionsInHelper ( )
protected

Definition at line 139 of file ilWebDAVLockUriPathResolverTest.php.

140 {
141 $mocked_repo_helper = $this->createMock(ilWebDAVRepositoryHelper::class);
142 return new ilWebDAVLockUriPathResolver($mocked_repo_helper);
143 }

Referenced by testGetRefIdForInvalidRefMountThrowsNotFoundError(), testGetRefIdForValidRefMountReturnsRefId(), testGetRefIdForWebDAVPathWhenPathHasNoValidStartElementThrowsBadRequestError(), and testGetRefIdForWebDAVWithValidClientIdReturnsRootFolderId().

+ Here is the caller graph for this function:

◆ setUp()

ilWebDAVLockUriPathResolverTest::setUp ( )

Definition at line 31 of file ilWebDAVLockUriPathResolverTest.php.

31 : void
32 {
33 $this->webdav_test_helper = new ilWebDAVTestHelper();
34 define('CLIENT_ID', $this->webdav_test_helper->getClientId());
35 define('ROOT_FOLDER_ID', 1);
36 }

◆ testGetRefIdForInvalidRefMountThrowsNotFoundError()

ilWebDAVLockUriPathResolverTest::testGetRefIdForInvalidRefMountThrowsNotFoundError ( )

Definition at line 73 of file ilWebDAVLockUriPathResolverTest.php.

73 : void
74 {
75 $invalid_refmount_path = [
76 $this->webdav_test_helper->getClientId() . '/ref_0',
77 $this->webdav_test_helper->getClientId() . '/ref_-23',
78 $this->webdav_test_helper->getClientId() . '/ref_adfadf'
79 ];
81
82 foreach ($invalid_refmount_path as $current_path) {
83 try {
84 $path_resolver->getRefIdForWebDAVPath($current_path);
85 $this->assertFalse('This should not happen!');
86 } catch (NotFound $e) {
87 $this->assertSame('Mount point not found', $e->getMessage());
88 }
89 }
90 }

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

+ Here is the call graph for this function:

◆ testGetRefIdForValidRefMountReturnsRefId()

ilWebDAVLockUriPathResolverTest::testGetRefIdForValidRefMountReturnsRefId ( )

Definition at line 65 of file ilWebDAVLockUriPathResolverTest.php.

65 : void
66 {
67 $path_with_valid_ref_id = $this->webdav_test_helper->getClientId() . '/ref_50';
69
70 $this->assertSame(50, $path_resolver->getRefIdForWebDAVPath($path_with_valid_ref_id));
71 }

References getPathResolverWithoutExpectationForFunctionsInHelper().

+ Here is the call graph for this function:

◆ testGetRefIdForWebDAVPathWhenPathHasNoValidStartElementThrowsBadRequestError()

ilWebDAVLockUriPathResolverTest::testGetRefIdForWebDAVPathWhenPathHasNoValidStartElementThrowsBadRequestError ( )

Definition at line 38 of file ilWebDAVLockUriPathResolverTest.php.

38 : void
39 {
40 $invalid_path = [
41 "",
42 "invalid_client_id",
43 "invalid_client_id/and_some_path"
44 ];
46
47 foreach ($invalid_path as $current_path) {
48 try {
49 $path_resolver->getRefIdForWebDAVPath($current_path);
50 $this->assertFalse('This should not happen!');
51 } catch (BadRequest $e) {
52 $this->assertSame('Invalid client id given', $e->getMessage());
53 }
54 }
55 }

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

+ Here is the call graph for this function:

◆ testGetRefIdForWebDAVPathWithInvalidPathThrowsNotFoundError()

ilWebDAVLockUriPathResolverTest::testGetRefIdForWebDAVPathWithInvalidPathThrowsNotFoundError ( )

Definition at line 112 of file ilWebDAVLockUriPathResolverTest.php.

112 : void
113 {
114 // Arrange
115 $pathes = [
116 $this->webdav_test_helper->getClientId() . '/Non exitent First Child/Last Third Child' => [
117 'parameters' => [1, 4],
118 'error_message' => 'Node not found'
119 ],
120 $this->webdav_test_helper->getClientId() . '/Last Child/Non existent Last Child' => [
121 'parameters' => [2, 8],
122 'error_message' => 'Last node not found'
123 ]
124 ];
125
126 foreach ($pathes as $path => $additional_info) {
128 ...$additional_info['parameters']
129 );
130 try {
131 $path_resolver->getRefIdForWebDAVPath($path);
132 $this->assertFalse('This should not happen!');
133 } catch (NotFound $e) {
134 $this->assertEquals($additional_info['error_message'], $e->getMessage());
135 }
136 }
137 }
getPathResolverWithExpectationForFunctionsInHelper(int $expects_children, int $expects_ref_id)
$path
Definition: ltiservices.php:30

References Vendor\Package\$e, and $path.

◆ testGetRefIdForWebDAVPathWithPathPointingToElementWithIdenticalTitleReturnsRefIdOfLastIdenticalElement()

ilWebDAVLockUriPathResolverTest::testGetRefIdForWebDAVPathWithPathPointingToElementWithIdenticalTitleReturnsRefIdOfLastIdenticalElement ( )

Definition at line 102 of file ilWebDAVLockUriPathResolverTest.php.

103 : void {
104 // Arrange
105 $path = $this->webdav_test_helper->getClientId() . '/Second Child/Second First Child';
106 $expected_ref_id = 72;
107 $path_resolver = $this->getPathResolverWithExpectationForFunctionsInHelper(2, 11);
108
109 $this->assertSame($expected_ref_id, $path_resolver->getRefIdForWebDAVPath($path));
110 }

◆ testGetRefIdForWebDAVPathWithPathReturnsRefIdOfLastElement()

ilWebDAVLockUriPathResolverTest::testGetRefIdForWebDAVPathWithPathReturnsRefIdOfLastElement ( )

Definition at line 92 of file ilWebDAVLockUriPathResolverTest.php.

92 : void
93 {
94 // Arrange
95 $path = $this->webdav_test_helper->getClientId() . '/Last Child/Last Third Child';
96 $expected_ref_id = 2335634322;
97 $path_resolver = $this->getPathResolverWithExpectationForFunctionsInHelper(2, 8);
98
99 $this->assertSame($expected_ref_id, $path_resolver->getRefIdForWebDAVPath($path));
100 }

References $path, and getPathResolverWithExpectationForFunctionsInHelper().

+ Here is the call graph for this function:

◆ testGetRefIdForWebDAVWithValidClientIdReturnsRootFolderId()

ilWebDAVLockUriPathResolverTest::testGetRefIdForWebDAVWithValidClientIdReturnsRootFolderId ( )

Definition at line 57 of file ilWebDAVLockUriPathResolverTest.php.

57 : void
58 {
59 $path_only_clientid = $this->webdav_test_helper->getClientId();
61
62 $this->assertSame(1, $path_resolver->getRefIdForWebDAVPath($path_only_clientid));
63 }

References getPathResolverWithoutExpectationForFunctionsInHelper().

+ Here is the call graph for this function:

Field Documentation

◆ $webdav_test_helper

ilWebDAVTestHelper ilWebDAVLockUriPathResolverTest::$webdav_test_helper
protected

Definition at line 29 of file ilWebDAVLockUriPathResolverTest.php.


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