ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilWebDAVLockUriPathResolverTest Class Reference
+ 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

Definition at line 27 of file ilWebDAVLockUriPathResolverTest.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 31 of file ilWebDAVLockUriPathResolverTest.php.

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

32  {
33  $this->webdav_test_helper = new ilWebDAVTestHelper();
34  parent::__construct($name, $data, $dataName);
35  }
__construct(Container $dic, ilPlugin $plugin)
+ 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 150 of file ilWebDAVLockUriPathResolverTest.php.

References $ref_id, and ilWebDAVTestHelper\getTree().

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

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']
160  );
161  $mocked_repo_helper->expects($this->exactly($expects_ref_id))
162  ->method('getObjectTitleFromRefId')->willReturnCallback(
163  fn(int $ref_id): string => $tree[$ref_id]['title']
164  );
165  return new ilWebDAVLockUriPathResolver($mocked_repo_helper);
166  }
$ref_id
Definition: ltiauth.php:65
+ 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 37 of file ilWebDAVLockUriPathResolverTest.php.

37  : void
38  {
39  define('CLIENT_ID', $this->webdav_test_helper->getClientId());
40  define('ROOT_FOLDER_ID', 1);
41  }

◆ testGetRefIdForInvalidRefMountThrowsNotFoundError()

ilWebDAVLockUriPathResolverTest::testGetRefIdForInvalidRefMountThrowsNotFoundError ( )

Definition at line 78 of file ilWebDAVLockUriPathResolverTest.php.

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

78  : void
79  {
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'
84  ];
86 
87  foreach ($invalid_refmount_path as $current_path) {
88  try {
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());
93  }
94  }
95  }
+ Here is the call graph for this function:

◆ testGetRefIdForValidRefMountReturnsRefId()

ilWebDAVLockUriPathResolverTest::testGetRefIdForValidRefMountReturnsRefId ( )

Definition at line 70 of file ilWebDAVLockUriPathResolverTest.php.

References getPathResolverWithoutExpectationForFunctionsInHelper().

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

◆ testGetRefIdForWebDAVPathWhenPathHasNoValidStartElementThrowsBadRequestError()

ilWebDAVLockUriPathResolverTest::testGetRefIdForWebDAVPathWhenPathHasNoValidStartElementThrowsBadRequestError ( )

Definition at line 43 of file ilWebDAVLockUriPathResolverTest.php.

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

43  : void
44  {
45  $invalid_path = [
46  "",
47  "invalid_client_id",
48  "invalid_client_id/and_some_path"
49  ];
51 
52  foreach ($invalid_path as $current_path) {
53  try {
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());
58  }
59  }
60  }
+ Here is the call graph for this function:

◆ testGetRefIdForWebDAVPathWithInvalidPathThrowsNotFoundError()

ilWebDAVLockUriPathResolverTest::testGetRefIdForWebDAVPathWithInvalidPathThrowsNotFoundError ( )

Definition at line 117 of file ilWebDAVLockUriPathResolverTest.php.

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

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

◆ testGetRefIdForWebDAVPathWithPathPointingToElementWithIdenticalTitleReturnsRefIdOfLastIdenticalElement()

ilWebDAVLockUriPathResolverTest::testGetRefIdForWebDAVPathWithPathPointingToElementWithIdenticalTitleReturnsRefIdOfLastIdenticalElement ( )

Definition at line 107 of file ilWebDAVLockUriPathResolverTest.php.

References $path, and getPathResolverWithExpectationForFunctionsInHelper().

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

◆ testGetRefIdForWebDAVPathWithPathReturnsRefIdOfLastElement()

ilWebDAVLockUriPathResolverTest::testGetRefIdForWebDAVPathWithPathReturnsRefIdOfLastElement ( )

Definition at line 97 of file ilWebDAVLockUriPathResolverTest.php.

References $path, and getPathResolverWithExpectationForFunctionsInHelper().

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

◆ testGetRefIdForWebDAVWithValidClientIdReturnsRootFolderId()

ilWebDAVLockUriPathResolverTest::testGetRefIdForWebDAVWithValidClientIdReturnsRootFolderId ( )

Definition at line 62 of file ilWebDAVLockUriPathResolverTest.php.

References getPathResolverWithoutExpectationForFunctionsInHelper().

62  : void
63  {
64  $path_only_clientid = $this->webdav_test_helper->getClientId();
66 
67  $this->assertEquals(1, $path_resolver->getRefIdForWebDAVPath($path_only_clientid));
68  }
+ 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: