ILIAS  release_8 Revision v8.24
ilWebDAVLockUriPathResolverTest Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. 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

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning @runTestsInSeparateProcesses @preserveGlobalState disabled

Definition at line 31 of file ilWebDAVLockUriPathResolverTest.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 35 of file ilWebDAVLockUriPathResolverTest.php.

36 {
37 $this->webdav_test_helper = new ilWebDAVTestHelper();
38 parent::__construct($name, $data, $dataName);
39 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if($format !==null) $name
Definition: metadata.php:247
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References $data, $name, and ILIAS\GlobalScreen\Provider\__construct().

+ 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 154 of file ilWebDAVLockUriPathResolverTest.php.

155 {
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 function (int $parent_ref) use ($tree): array {
162 return $tree[$parent_ref]['children'];
163 }
164 );
165 $mocked_repo_helper->expects($this->exactly($expects_ref_id))
166 ->method('getObjectTitleFromRefId')->willReturnCallback(
167 function (int $ref_id) use ($tree): string {
168 return $tree[$ref_id]['title'];
169 }
170 );
171 return new ilWebDAVLockUriPathResolver($mocked_repo_helper);
172 }
$ref_id
Definition: ltiauth.php:67

References $ref_id, and $webdav_test_helper.

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

+ Here is the caller graph for this function:

◆ getPathResolverWithoutExpectationForFunctionsInHelper()

ilWebDAVLockUriPathResolverTest::getPathResolverWithoutExpectationForFunctionsInHelper ( )
protected

Definition at line 148 of file ilWebDAVLockUriPathResolverTest.php.

149 {
150 $mocked_repo_helper = $this->createMock(ilWebDAVRepositoryHelper::class);
151 return new ilWebDAVLockUriPathResolver($mocked_repo_helper);
152 }

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

+ Here is the caller graph for this function:

◆ setUp()

ilWebDAVLockUriPathResolverTest::setUp ( )

Definition at line 41 of file ilWebDAVLockUriPathResolverTest.php.

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

◆ testGetRefIdForInvalidRefMountThrowsNotFoundError()

ilWebDAVLockUriPathResolverTest::testGetRefIdForInvalidRefMountThrowsNotFoundError ( )

Definition at line 82 of file ilWebDAVLockUriPathResolverTest.php.

82 : void
83 {
84 $invalid_refmount_path = [
85 $this->webdav_test_helper->getClientId() . '/ref_0',
86 $this->webdav_test_helper->getClientId() . '/ref_-23',
87 $this->webdav_test_helper->getClientId() . '/ref_adfadf'
88 ];
90
91 foreach ($invalid_refmount_path as $current_path) {
92 try {
93 $path_resolver->getRefIdForWebDAVPath($current_path);
94 $this->assertFalse('This should not happen!');
95 } catch (NotFound $e) {
96 $this->assertEquals('Mount point not found', $e->getMessage());
97 }
98 }
99 }

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

+ Here is the call graph for this function:

◆ testGetRefIdForValidRefMountReturnsRefId()

ilWebDAVLockUriPathResolverTest::testGetRefIdForValidRefMountReturnsRefId ( )

Definition at line 74 of file ilWebDAVLockUriPathResolverTest.php.

74 : void
75 {
76 $path_with_valid_ref_id = $this->webdav_test_helper->getClientId() . '/ref_50';
78
79 $this->assertEquals(50, $path_resolver->getRefIdForWebDAVPath($path_with_valid_ref_id));
80 }

References getPathResolverWithoutExpectationForFunctionsInHelper().

+ Here is the call graph for this function:

◆ testGetRefIdForWebDAVPathWhenPathHasNoValidStartElementThrowsBadRequestError()

ilWebDAVLockUriPathResolverTest::testGetRefIdForWebDAVPathWhenPathHasNoValidStartElementThrowsBadRequestError ( )

Definition at line 47 of file ilWebDAVLockUriPathResolverTest.php.

47 : void
48 {
49 $invalid_path = [
50 "",
51 "invalid_client_id",
52 "invalid_client_id/and_some_path"
53 ];
55
56 foreach ($invalid_path as $current_path) {
57 try {
58 $path_resolver->getRefIdForWebDAVPath($current_path);
59 $this->assertFalse('This should not happen!');
60 } catch (BadRequest $e) {
61 $this->assertEquals('Invalid client id given', $e->getMessage());
62 }
63 }
64 }

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

+ Here is the call graph for this function:

◆ testGetRefIdForWebDAVPathWithInvalidPathThrowsNotFoundError()

ilWebDAVLockUriPathResolverTest::testGetRefIdForWebDAVPathWithInvalidPathThrowsNotFoundError ( )

Definition at line 121 of file ilWebDAVLockUriPathResolverTest.php.

121 : void
122 {
123 // Arrange
124 $pathes = [
125 $this->webdav_test_helper->getClientId() . '/Non exitent First Child/Last Third Child' => [
126 'parameters' => [1, 4],
127 'error_message' => 'Node not found'
128 ],
129 $this->webdav_test_helper->getClientId() . '/Last Child/Non existent Last Child' => [
130 'parameters' => [2, 8],
131 'error_message' => 'Last node not found'
132 ]
133 ];
134
135 foreach ($pathes as $path => $additional_info) {
137 ...$additional_info['parameters']
138 );
139 try {
140 $path_resolver->getRefIdForWebDAVPath($path);
141 $this->assertFalse('This should not happen!');
142 } catch (NotFound $e) {
143 $this->assertEquals($additional_info['error_message'], $e->getMessage());
144 }
145 }
146 }
getPathResolverWithExpectationForFunctionsInHelper(int $expects_children, int $expects_ref_id)
$path
Definition: ltiservices.php:32

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

+ Here is the call graph for this function:

◆ testGetRefIdForWebDAVPathWithPathPointingToElementWithIdenticalTitleReturnsRefIdOfLastIdenticalElement()

ilWebDAVLockUriPathResolverTest::testGetRefIdForWebDAVPathWithPathPointingToElementWithIdenticalTitleReturnsRefIdOfLastIdenticalElement ( )

Definition at line 111 of file ilWebDAVLockUriPathResolverTest.php.

111 : void
112 {
113 // Arrange
114 $path = $this->webdav_test_helper->getClientId() . '/Second Child/Second First Child';
115 $expected_ref_id = 72;
116 $path_resolver = $this->getPathResolverWithExpectationForFunctionsInHelper(2, 11);
117
118 $this->assertEquals($expected_ref_id, $path_resolver->getRefIdForWebDAVPath($path));
119 }

References $path, and getPathResolverWithExpectationForFunctionsInHelper().

+ Here is the call graph for this function:

◆ testGetRefIdForWebDAVPathWithPathReturnsRefIdOfLastElement()

ilWebDAVLockUriPathResolverTest::testGetRefIdForWebDAVPathWithPathReturnsRefIdOfLastElement ( )

Definition at line 101 of file ilWebDAVLockUriPathResolverTest.php.

101 : void
102 {
103 // Arrange
104 $path = $this->webdav_test_helper->getClientId() . '/Last Child/Last Third Child';
105 $expected_ref_id = 2335634322;
106 $path_resolver = $this->getPathResolverWithExpectationForFunctionsInHelper(2, 8);
107
108 $this->assertEquals($expected_ref_id, $path_resolver->getRefIdForWebDAVPath($path));
109 }

References $path, and getPathResolverWithExpectationForFunctionsInHelper().

+ Here is the call graph for this function:

◆ testGetRefIdForWebDAVWithValidClientIdReturnsRootFolderId()

ilWebDAVLockUriPathResolverTest::testGetRefIdForWebDAVWithValidClientIdReturnsRootFolderId ( )

Definition at line 66 of file ilWebDAVLockUriPathResolverTest.php.

66 : void
67 {
68 $path_only_clientid = $this->webdav_test_helper->getClientId();
70
71 $this->assertEquals(1, $path_resolver->getRefIdForWebDAVPath($path_only_clientid));
72 }

References getPathResolverWithoutExpectationForFunctionsInHelper().

+ Here is the call graph for this function:

Field Documentation

◆ $webdav_test_helper

ilWebDAVTestHelper ilWebDAVLockUriPathResolverTest::$webdav_test_helper
protected

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