ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilDAVContainerTest Class Reference
+ Inheritance diagram for ilDAVContainerTest:
+ Collaboration diagram for ilDAVContainerTest:

Public Member Functions

 testGetNameGetsObjectTitle ()
 
 testGetChildWithExistingNameOfFolderOrFileReturnsIlObject ()
 
 testGetChildWithExistingNonDavableNameThrowsNotFoundError ()
 
 testGetChildWithExistingNameOfFolderOrFileWithoutAccessThrowsNotFoundError ()
 
 testGetChildWithNonExistentNameOfFolderOrFileThrowsNotFoundError ()
 
 testGetChildWithExistingNameOfOtherObjectTypeThrowsNotFoundError ()
 
 testGetChilrendWithExistingNameOfFolderOrFileReturnsArrayOfObjects ()
 
 testGetChilrendWithExistingNameOfFolderOrFileReturnsArrayWithProblemInfoFile ()
 
 testGetChildrenFromFolderWithOnlyNonDavableNamedContentReturnsEmptyArray ()
 
 testChildExistsWithExistingNameOfFolderOrFileReturnsTrue ()
 
 testChildExistsWithExistingNameOfFolderOrFileWhenOtherObjectOfSameNameExistsReturnsTrue ()
 
 testChildExistsWithExistingNonDavableNameReturnsFalse ()
 
 testChildExistsWithExistingNameOfFolderOrFileWithoutAccessReturnsFalse ()
 
 testChildExistsWithNonExistentNameOfFolderOrFileReturnsFalse ()
 
 testChildExistsWithExistingNameOfOtherObjectTypeReturnsFalse ()
 
 testSetNameWithoutPermissionsThrowsForbiddenError ()
 
 testSetNameWithNonDavableNameThrowsForbiddenError ()
 
 testCreateFileWithoutPermissionsThrowsForbiddenError ()
 
 testCreateDirectoryWithoutPermissionsThrowsForbiddenError ()
 
 testCreateDirectoryWithNonDavableNameThrowsForbiddenError ()
 
 testDeleteWithoutPermissionsThrowsForbiddenError ()
 

Protected Member Functions

 getChildrenTest (int $ref_id, array $additional_information)
 
 getDAVContainerWithExpectationForFunctions (int $object_ref_id, int $expects_object, int $expects_problem_info_file=0, int $expects_child_ref=1, bool $for_create=false)
 

Detailed Description

Definition at line 28 of file class.ilDAVContainerTest.php.

Member Function Documentation

◆ getChildrenTest()

ilDAVContainerTest::getChildrenTest ( int  $ref_id,
array  $additional_information 
)
protected
Parameters
mixed[]$additional_information

Definition at line 196 of file class.ilDAVContainerTest.php.

References $i, and getDAVContainerWithExpectationForFunctions().

Referenced by testGetChilrendWithExistingNameOfFolderOrFileReturnsArrayOfObjects(), and testGetChilrendWithExistingNameOfFolderOrFileReturnsArrayWithProblemInfoFile().

196  : void
197  {
198  $dav_container = $this->getDAVContainerWithExpectationForFunctions(
199  $ref_id,
200  $additional_information['expects_objects'],
201  $additional_information['expects_problem_info_file']
202  );
203  $children = $dav_container->getChildren();
204  $this->assertEquals(count($additional_information['names']), count($children));
205  for ($i = 0; $i < count($children); $i++) {
206  $this->assertInstanceOf($additional_information['classes'][$i], $children[$additional_information['ref_id'][$i]]);
207  $this->assertEquals($additional_information['names'][$i], $children[$additional_information['ref_id'][$i]]->getName());
208  }
209  }
$ref_id
Definition: ltiauth.php:67
getDAVContainerWithExpectationForFunctions(int $object_ref_id, int $expects_object, int $expects_problem_info_file=0, int $expects_child_ref=1, bool $for_create=false)
$i
Definition: metadata.php:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDAVContainerWithExpectationForFunctions()

ilDAVContainerTest::getDAVContainerWithExpectationForFunctions ( int  $object_ref_id,
int  $expects_object,
int  $expects_problem_info_file = 0,
int  $expects_child_ref = 1,
bool  $for_create = false 
)
protected

Definition at line 426 of file class.ilDAVContainerTest.php.

References $ref_id, $type, ilWebDAVNotDavableException\OBJECT_HIDDEN, ilWebDAVNotDavableException\OBJECT_TITLE_NOT_DAVABLE, and ilWebDAVNotDavableException\OBJECT_TYPE_NOT_DAVABLE.

Referenced by getChildrenTest(), testChildExistsWithExistingNameOfFolderOrFileReturnsTrue(), testChildExistsWithExistingNameOfFolderOrFileWhenOtherObjectOfSameNameExistsReturnsTrue(), testChildExistsWithExistingNameOfFolderOrFileWithoutAccessReturnsFalse(), testChildExistsWithExistingNameOfOtherObjectTypeReturnsFalse(), testChildExistsWithExistingNonDavableNameReturnsFalse(), testChildExistsWithNonExistentNameOfFolderOrFileReturnsFalse(), testCreateDirectoryWithNonDavableNameThrowsForbiddenError(), testCreateDirectoryWithoutPermissionsThrowsForbiddenError(), testCreateFileWithoutPermissionsThrowsForbiddenError(), testDeleteWithoutPermissionsThrowsForbiddenError(), testGetChildrenFromFolderWithOnlyNonDavableNamedContentReturnsEmptyArray(), testGetChildWithExistingNameOfFolderOrFileReturnsIlObject(), testGetChildWithExistingNameOfFolderOrFileWithoutAccessThrowsNotFoundError(), testGetChildWithExistingNameOfOtherObjectTypeThrowsNotFoundError(), testGetChildWithExistingNonDavableNameThrowsNotFoundError(), testGetChildWithNonExistentNameOfFolderOrFileThrowsNotFoundError(), testSetNameWithNonDavableNameThrowsForbiddenError(), and testSetNameWithoutPermissionsThrowsForbiddenError().

432  : ilDAVContainer {
433  $object_folder = $this->createPartialMock(ilObjFolder::class, []);
434  $object_folder->setRefId($object_ref_id);
435  $user = $this->createStub(ilObjUser::class);
436  $request = $this->createStub('Psr\Http\Message\RequestInterface');
437 
438  $webdav_test_helper = new ilWebDAVTestHelper();
439  $tree = $webdav_test_helper->getTree();
440 
441  $mocked_dav_factory = $this->createPartialMock(ilWebDAVObjFactory::class, ['retrieveDAVObjectByRefID', 'getProblemInfoFile']);
442  $mocked_dav_factory->expects($this->exactly($expects_object))
443  ->method('retrieveDAVObjectByRefID')->willReturnCallback(
444  function (int $ref_id) use ($tree): INode {
445  if ($tree[$ref_id]['access'] === 'none') {
446  throw new Forbidden("No read permission for object with reference ID $ref_id");
447  }
448 
449  if ($tree[$ref_id]['type'] === 'fold') {
450  $obj_class = ilDAVContainer::class;
451  } elseif ($tree[$ref_id]['type'] === 'file') {
452  $obj_class = ilDAVFile::class;
453  } else {
455  }
456 
457  if ($this->hasTitleForbiddenChars($tree[$ref_id]['title'])) {
459  }
460 
461  if ($this->isHiddenFile($tree[$ref_id]['title'])) {
463  }
464 
465  $object = $this->createMock($obj_class);
466  $object->expects($this->atMost(3))->method('getName')->willReturn($tree[$ref_id]['title']);
467  return $object;
468  }
469  );
470  $mocked_dav_factory->expects($this->exactly($expects_problem_info_file))
471  ->method('getProblemInfoFile')->willReturnCallback(
472  function (int $ref_id): ilDAVProblemInfoFile {
473  $problem_info_file = $this->createMock(ilDAVProblemInfoFile::class);
474  $problem_info_file->expects($this->atMost(2))->method('getName')->willReturn('Problem Info File');
475  return $problem_info_file;
476  }
477  );
478 
479  $mocked_repo_helper = $this->createPartialMock(ilWebDAVRepositoryHelper::class, ['getChildrenOfRefId', 'checkcreateAccessForType', 'checkAccess']);
480  $mocked_repo_helper->expects($this->exactly($expects_child_ref))
481  ->method('getChildrenOfRefId')->willReturnCallback(
482  function (int $parent_ref) use ($tree): array {
483  return $tree[$parent_ref]['children'];
484  }
485  );
486  $mocked_repo_helper->expects($this->atMost(1))
487  ->method('checkcreateAccessForType')->willReturnCallback(
488  function ($parent_ref, $type) use ($tree) {
489  if ($tree[$parent_ref]['access'] === 'write') {
490  return true;
491  }
492 
493  return false;
494  }
495  );
496  $mocked_repo_helper->expects($this->atMost(1))
497  ->method('checkAccess')->willReturnCallback(
498  function (string $permission, int $ref_id) use ($tree) {
499  if (in_array($permission, ['write', 'delete']) && $tree[$ref_id]['access'] === 'write') {
500  return true;
501  }
502 
503  return false;
504  }
505  );
506 
507  if ($for_create) {
508  $object_child = $this->createPartialMock(ilObjFolder::class, []);
509  $object_child->setType('fold');
510  $dav_container = new ilDAVContainerWithOverridenGetChildCollection($object_folder, $user, $request, $mocked_dav_factory, $mocked_repo_helper);
511  $dav_container->setChildcollection($object_child);
512  return $dav_container;
513  }
514 
515  return new ilDAVContainer($object_folder, $user, $request, $mocked_dav_factory, $mocked_repo_helper);
516  }
$type
$ref_id
Definition: ltiauth.php:67
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ testChildExistsWithExistingNameOfFolderOrFileReturnsTrue()

ilDAVContainerTest::testChildExistsWithExistingNameOfFolderOrFileReturnsTrue ( )

Definition at line 224 of file class.ilDAVContainerTest.php.

References $ref_id, and getDAVContainerWithExpectationForFunctions().

224  : void
225  {
226  $ref_ids = [
227  '7' => [
228  'name' => 'Second Fourth Child',
229  'expects_objects' => 6
230  ],
231  '23356343' => [
232  'name' => 'Last Last Child',
233  'expects_objects' => 4
234  ]
235  ];
236 
237  foreach ($ref_ids as $ref_id => $additional_information) {
238  $dav_container = $this->getDAVContainerWithExpectationForFunctions(
239  (int) $ref_id,
240  $additional_information['expects_objects']
241  );
242  $this->assertTrue($dav_container->childExists($additional_information['name']));
243  }
244  }
$ref_id
Definition: ltiauth.php:67
getDAVContainerWithExpectationForFunctions(int $object_ref_id, int $expects_object, int $expects_problem_info_file=0, int $expects_child_ref=1, bool $for_create=false)
+ Here is the call graph for this function:

◆ testChildExistsWithExistingNameOfFolderOrFileWhenOtherObjectOfSameNameExistsReturnsTrue()

ilDAVContainerTest::testChildExistsWithExistingNameOfFolderOrFileWhenOtherObjectOfSameNameExistsReturnsTrue ( )

Definition at line 246 of file class.ilDAVContainerTest.php.

References $ref_id, and getDAVContainerWithExpectationForFunctions().

246  : void
247  {
248  $ref_id = 7;
249  $additional_information = [
250  'name' => 'Second Second Child',
251  'expects_objects' => 4
252  ];
253 
254  $dav_container = $this->getDAVContainerWithExpectationForFunctions(
255  $ref_id,
256  $additional_information['expects_objects']
257  );
258  $this->assertTrue($dav_container->childExists($additional_information['name']));
259  }
$ref_id
Definition: ltiauth.php:67
getDAVContainerWithExpectationForFunctions(int $object_ref_id, int $expects_object, int $expects_problem_info_file=0, int $expects_child_ref=1, bool $for_create=false)
+ Here is the call graph for this function:

◆ testChildExistsWithExistingNameOfFolderOrFileWithoutAccessReturnsFalse()

ilDAVContainerTest::testChildExistsWithExistingNameOfFolderOrFileWithoutAccessReturnsFalse ( )

Definition at line 276 of file class.ilDAVContainerTest.php.

References $ref_id, and getDAVContainerWithExpectationForFunctions().

276  : void
277  {
278  $ref_ids = [
279  '7' => [
280  'name' => 'Second Third Child',
281  'expects_objects' => 7
282  ],
283  '23356343' => [
284  'name' => 'Last Third Child',
285  'expects_objects' => 4
286  ]
287  ];
288 
289  foreach ($ref_ids as $ref_id => $additional_information) {
290  $dav_container = $this->getDAVContainerWithExpectationForFunctions(
291  (int) $ref_id,
292  $additional_information['expects_objects']
293  );
294  $this->assertFalse($dav_container->childExists($additional_information['name']));
295  }
296  }
$ref_id
Definition: ltiauth.php:67
getDAVContainerWithExpectationForFunctions(int $object_ref_id, int $expects_object, int $expects_problem_info_file=0, int $expects_child_ref=1, bool $for_create=false)
+ Here is the call graph for this function:

◆ testChildExistsWithExistingNameOfOtherObjectTypeReturnsFalse()

ilDAVContainerTest::testChildExistsWithExistingNameOfOtherObjectTypeReturnsFalse ( )

Definition at line 311 of file class.ilDAVContainerTest.php.

References $ref_id, and getDAVContainerWithExpectationForFunctions().

311  : void
312  {
313  $ref_ids = [
314  '7' => [
315  'name' => 'Second Last Child',
316  'expects_objects' => 7
317  ],
318  '23356343' => [
319  'name' => 'Last Second Child',
320  'expects_objects' => 4
321  ]
322  ];
323 
324  foreach ($ref_ids as $ref_id => $additional_information) {
325  $dav_container = $this->getDAVContainerWithExpectationForFunctions(
326  (int) $ref_id,
327  $additional_information['expects_objects']
328  );
329 
330  $this->assertFalse($dav_container->childExists($additional_information['name']));
331  }
332  }
$ref_id
Definition: ltiauth.php:67
getDAVContainerWithExpectationForFunctions(int $object_ref_id, int $expects_object, int $expects_problem_info_file=0, int $expects_child_ref=1, bool $for_create=false)
+ Here is the call graph for this function:

◆ testChildExistsWithExistingNonDavableNameReturnsFalse()

ilDAVContainerTest::testChildExistsWithExistingNonDavableNameReturnsFalse ( )

Definition at line 261 of file class.ilDAVContainerTest.php.

References $ref_id, and getDAVContainerWithExpectationForFunctions().

261  : void
262  {
263  $ref_id = '22';
264  $webdav_test_helper = new ilWebDAVTestHelper();
265  $tree = $webdav_test_helper->getTree();
266 
267  foreach ($tree[$ref_id]['children'] as $child_ref) {
268  $dav_container = $this->getDAVContainerWithExpectationForFunctions(
269  (int) $ref_id,
270  11
271  );
272  $this->assertFalse($dav_container->childExists($tree[$child_ref]['title']));
273  }
274  }
$ref_id
Definition: ltiauth.php:67
getDAVContainerWithExpectationForFunctions(int $object_ref_id, int $expects_object, int $expects_problem_info_file=0, int $expects_child_ref=1, bool $for_create=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ testChildExistsWithNonExistentNameOfFolderOrFileReturnsFalse()

ilDAVContainerTest::testChildExistsWithNonExistentNameOfFolderOrFileReturnsFalse ( )

Definition at line 298 of file class.ilDAVContainerTest.php.

References $name, $ref_id, and getDAVContainerWithExpectationForFunctions().

298  : void
299  {
300  $ref_id = 7;
301  $name = 'None existent name';
302 
303  $dav_container = $this->getDAVContainerWithExpectationForFunctions(
304  $ref_id,
305  7
306  );
307 
308  $this->assertFalse($dav_container->childExists($name));
309  }
if($format !==null) $name
Definition: metadata.php:247
$ref_id
Definition: ltiauth.php:67
getDAVContainerWithExpectationForFunctions(int $object_ref_id, int $expects_object, int $expects_problem_info_file=0, int $expects_child_ref=1, bool $for_create=false)
+ Here is the call graph for this function:

◆ testCreateDirectoryWithNonDavableNameThrowsForbiddenError()

ilDAVContainerTest::testCreateDirectoryWithNonDavableNameThrowsForbiddenError ( )

Definition at line 394 of file class.ilDAVContainerTest.php.

References Vendor\Package\$e, $ref_id, and getDAVContainerWithExpectationForFunctions().

394  : void
395  {
396  $ref_id = 7221;
397  $webdav_test_helper = new ilWebDAVTestHelper();
398  $tree = $webdav_test_helper->getTree();
399 
400  foreach ($tree['22']['children'] as $invalid_object) {
401  $dav_container = $this->getDAVContainerWithExpectationForFunctions($ref_id, 0, 0, 0, true);
402 
403  try {
404  $dav_container->createDirectory($tree[$invalid_object]['title']);
405  $this->assertFalse('This should not happen!');
406  } catch (Forbidden $e) {
407  $this->assertEquals('Forbidden characters in title', $e->getMessage());
408  }
409  }
410  }
$ref_id
Definition: ltiauth.php:67
getDAVContainerWithExpectationForFunctions(int $object_ref_id, int $expects_object, int $expects_problem_info_file=0, int $expects_child_ref=1, bool $for_create=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ testCreateDirectoryWithoutPermissionsThrowsForbiddenError()

ilDAVContainerTest::testCreateDirectoryWithoutPermissionsThrowsForbiddenError ( )

Definition at line 380 of file class.ilDAVContainerTest.php.

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

380  : void
381  {
382  $parent_ref = 233563432;
383 
384  $dav_container = $this->getDAVContainerWithExpectationForFunctions($parent_ref, 0, 0, 0, true);
385 
386  try {
387  $dav_container->createDirectory('My New Folder');
388  $this->assertFalse('This should not happen!');
389  } catch (Forbidden $e) {
390  $this->assertEquals('Permission denied', $e->getMessage());
391  }
392  }
getDAVContainerWithExpectationForFunctions(int $object_ref_id, int $expects_object, int $expects_problem_info_file=0, int $expects_child_ref=1, bool $for_create=false)
+ Here is the call graph for this function:

◆ testCreateFileWithoutPermissionsThrowsForbiddenError()

ilDAVContainerTest::testCreateFileWithoutPermissionsThrowsForbiddenError ( )

Definition at line 366 of file class.ilDAVContainerTest.php.

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

366  : void
367  {
368  $parent_ref = 233563432;
369 
370  $dav_container = $this->getDAVContainerWithExpectationForFunctions($parent_ref, 0, 0, 0, false);
371 
372  try {
373  $dav_container->createFile('My New File.txt');
374  $this->assertFalse('This should not happen!');
375  } catch (Forbidden $e) {
376  $this->assertEquals('Permission denied', $e->getMessage());
377  }
378  }
getDAVContainerWithExpectationForFunctions(int $object_ref_id, int $expects_object, int $expects_problem_info_file=0, int $expects_child_ref=1, bool $for_create=false)
+ Here is the call graph for this function:

◆ testDeleteWithoutPermissionsThrowsForbiddenError()

ilDAVContainerTest::testDeleteWithoutPermissionsThrowsForbiddenError ( )

Definition at line 412 of file class.ilDAVContainerTest.php.

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

412  : void
413  {
414  $parent_ref = 233563432;
415 
416  $dav_container = $this->getDAVContainerWithExpectationForFunctions($parent_ref, 0, 0, 0);
417 
418  try {
419  $dav_container->delete();
420  $this->assertFalse('This should not happen!');
421  } catch (Forbidden $e) {
422  $this->assertEquals('Permission denied', $e->getMessage());
423  }
424  }
getDAVContainerWithExpectationForFunctions(int $object_ref_id, int $expects_object, int $expects_problem_info_file=0, int $expects_child_ref=1, bool $for_create=false)
+ Here is the call graph for this function:

◆ testGetChildrenFromFolderWithOnlyNonDavableNamedContentReturnsEmptyArray()

ilDAVContainerTest::testGetChildrenFromFolderWithOnlyNonDavableNamedContentReturnsEmptyArray ( )

Definition at line 211 of file class.ilDAVContainerTest.php.

References $ref_id, and getDAVContainerWithExpectationForFunctions().

211  : void
212  {
213  $ref_id = 22;
214 
215  $dav_container = $this->getDAVContainerWithExpectationForFunctions(
216  $ref_id,
217  11,
218  1
219  );
220  $children = $dav_container->getChildren();
221  $this->assertEquals(1, count($children));
222  }
$ref_id
Definition: ltiauth.php:67
getDAVContainerWithExpectationForFunctions(int $object_ref_id, int $expects_object, int $expects_problem_info_file=0, int $expects_child_ref=1, bool $for_create=false)
+ Here is the call graph for this function:

◆ testGetChildWithExistingNameOfFolderOrFileReturnsIlObject()

ilDAVContainerTest::testGetChildWithExistingNameOfFolderOrFileReturnsIlObject ( )

Definition at line 47 of file class.ilDAVContainerTest.php.

References $ref_id, and getDAVContainerWithExpectationForFunctions().

47  : void
48  {
49  $ref_ids = [
50  '7' => [
51  'name' => 'Second Fourth Child',
52  'class' => ilDAVContainer::class,
53  'expects_objects' => 7
54  ],
55  '23356343' => [
56  'name' => 'Last Last Child',
57  'class' => ilDAVFile::class,
58  'expects_objects' => 4
59  ]
60  ];
61 
62  foreach ($ref_ids as $ref_id => $additional_information) {
63  $dav_container = $this->getDAVContainerWithExpectationForFunctions(
64  (int) $ref_id,
65  $additional_information['expects_objects']
66  );
67  $object = $dav_container->getChild($additional_information['name']);
68  $this->assertInstanceOf($additional_information['class'], $object);
69  $this->assertEquals($additional_information['name'], $object->getName());
70  }
71  }
$ref_id
Definition: ltiauth.php:67
getDAVContainerWithExpectationForFunctions(int $object_ref_id, int $expects_object, int $expects_problem_info_file=0, int $expects_child_ref=1, bool $for_create=false)
+ Here is the call graph for this function:

◆ testGetChildWithExistingNameOfFolderOrFileWithoutAccessThrowsNotFoundError()

ilDAVContainerTest::testGetChildWithExistingNameOfFolderOrFileWithoutAccessThrowsNotFoundError ( )

Definition at line 94 of file class.ilDAVContainerTest.php.

References Vendor\Package\$e, $ref_id, and getDAVContainerWithExpectationForFunctions().

94  : void
95  {
96  $ref_ids = [
97  '7' => [
98  'name' => 'Second Third Child',
99  'expects_objects' => 7
100  ],
101  '23356343' => [
102  'name' => 'Last Third Child',
103  'expects_objects' => 4
104  ]
105  ];
106 
107  foreach ($ref_ids as $ref_id => $additional_information) {
108  try {
109  $dav_container = $this->getDAVContainerWithExpectationForFunctions(
110  (int) $ref_id,
111  $additional_information['expects_objects']
112  );
113  $dav_container->getChild($additional_information['name']);
114  $this->assertFalse('This should not happen');
115  } catch (NotFound $e) {
116  $this->assertEquals($additional_information['name'] . ' not found', $e->getMessage());
117  }
118  }
119  }
$ref_id
Definition: ltiauth.php:67
getDAVContainerWithExpectationForFunctions(int $object_ref_id, int $expects_object, int $expects_problem_info_file=0, int $expects_child_ref=1, bool $for_create=false)
+ Here is the call graph for this function:

◆ testGetChildWithExistingNameOfOtherObjectTypeThrowsNotFoundError()

ilDAVContainerTest::testGetChildWithExistingNameOfOtherObjectTypeThrowsNotFoundError ( )

Definition at line 138 of file class.ilDAVContainerTest.php.

References Vendor\Package\$e, $ref_id, and getDAVContainerWithExpectationForFunctions().

138  : void
139  {
140  $ref_ids = [
141  '7' => [
142  'name' => 'Second Last Child',
143  'expects_objects' => 7
144  ],
145  '23356343' => [
146  'name' => 'Last Second Child',
147  'expects_objects' => 4
148  ]
149  ];
150 
151  foreach ($ref_ids as $ref_id => $additional_information) {
152  try {
153  $dav_container = $this->getDAVContainerWithExpectationForFunctions(
154  (int) $ref_id,
155  $additional_information['expects_objects']
156  );
157  $dav_container->getChild($additional_information['name']);
158  $this->assertFalse('This should not happen');
159  } catch (NotFound $e) {
160  $this->assertEquals($additional_information['name'] . ' not found', $e->getMessage());
161  }
162  }
163  }
$ref_id
Definition: ltiauth.php:67
getDAVContainerWithExpectationForFunctions(int $object_ref_id, int $expects_object, int $expects_problem_info_file=0, int $expects_child_ref=1, bool $for_create=false)
+ Here is the call graph for this function:

◆ testGetChildWithExistingNonDavableNameThrowsNotFoundError()

ilDAVContainerTest::testGetChildWithExistingNonDavableNameThrowsNotFoundError ( )

Definition at line 73 of file class.ilDAVContainerTest.php.

References Vendor\Package\$e, $ref_id, and getDAVContainerWithExpectationForFunctions().

73  : void
74  {
75  $ref_id = '22';
76  $webdav_test_helper = new ilWebDAVTestHelper();
77  $tree = $webdav_test_helper->getTree();
78 
79  foreach ($tree[$ref_id]['children'] as $child_ref) {
80  $dav_container = $this->getDAVContainerWithExpectationForFunctions(
81  (int) $ref_id,
82  11
83  );
84  try {
85  $dav_container->getChild($tree[$child_ref]['title']);
86  $this->assertFalse('This should never happen');
87  } catch (NotFound $e) {
88  $this->assertEquals($tree[$child_ref]['title'] . ' not found', $e->getMessage());
89  ;
90  }
91  }
92  }
$ref_id
Definition: ltiauth.php:67
getDAVContainerWithExpectationForFunctions(int $object_ref_id, int $expects_object, int $expects_problem_info_file=0, int $expects_child_ref=1, bool $for_create=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ testGetChildWithNonExistentNameOfFolderOrFileThrowsNotFoundError()

ilDAVContainerTest::testGetChildWithNonExistentNameOfFolderOrFileThrowsNotFoundError ( )

Definition at line 121 of file class.ilDAVContainerTest.php.

References Vendor\Package\$e, $name, $ref_id, and getDAVContainerWithExpectationForFunctions().

121  : void
122  {
123  $ref_id = 7;
124  $name = 'None existent name';
125 
126  try {
127  $dav_container = $this->getDAVContainerWithExpectationForFunctions(
128  $ref_id,
129  7
130  );
131  $dav_container->getChild($name);
132  $this->assertFalse('This should not happen');
133  } catch (NotFound $e) {
134  $this->assertEquals("$name not found", $e->getMessage());
135  }
136  }
if($format !==null) $name
Definition: metadata.php:247
$ref_id
Definition: ltiauth.php:67
getDAVContainerWithExpectationForFunctions(int $object_ref_id, int $expects_object, int $expects_problem_info_file=0, int $expects_child_ref=1, bool $for_create=false)
+ Here is the call graph for this function:

◆ testGetChilrendWithExistingNameOfFolderOrFileReturnsArrayOfObjects()

ilDAVContainerTest::testGetChilrendWithExistingNameOfFolderOrFileReturnsArrayOfObjects ( )

Definition at line 165 of file class.ilDAVContainerTest.php.

References $ref_id, and getChildrenTest().

165  : void
166  {
167  $ref_id = 23356343;
168  $additional_information = [
169  'names' => ['Last First Child', 'Last Last Child'],
170  'classes' => [ilDAVContainer::class, ilDAVFile::class],
171  'ref_id' => ['233563432', '2335634323356343'],
172  'expects_objects' => 4,
173  'expects_problem_info_file' => 0
174  ];
175 
176  $this->getChildrenTest($ref_id, $additional_information);
177  }
getChildrenTest(int $ref_id, array $additional_information)
$ref_id
Definition: ltiauth.php:67
+ Here is the call graph for this function:

◆ testGetChilrendWithExistingNameOfFolderOrFileReturnsArrayWithProblemInfoFile()

ilDAVContainerTest::testGetChilrendWithExistingNameOfFolderOrFileReturnsArrayWithProblemInfoFile ( )

Definition at line 179 of file class.ilDAVContainerTest.php.

References $ref_id, and getChildrenTest().

179  : void
180  {
181  $ref_id = 7;
182  $additional_information = [
183  'names' => ['Second First Child', 'Second Second Child', 'Second Fourth Child', 'Problem Info File'],
184  'classes' => [ilDAVFile::class, ilDAVFile::class, ilDAVContainer::class, ilDAVProblemInfoFile::class],
185  'ref_id' => ['72', '78', '7221', '7222'],
186  'expects_objects' => 7,
187  'expects_problem_info_file' => 1,
188  ];
189 
190  $this->getChildrenTest($ref_id, $additional_information);
191  }
getChildrenTest(int $ref_id, array $additional_information)
$ref_id
Definition: ltiauth.php:67
+ Here is the call graph for this function:

◆ testGetNameGetsObjectTitle()

ilDAVContainerTest::testGetNameGetsObjectTitle ( )

Definition at line 32 of file class.ilDAVContainerTest.php.

32  : void
33  {
34  $object = $this->createMock(ilObjFolder::class);
35  $object->expects($this->once())->method('getTitle')->willReturn('Some random Title');
36 
37  $user = $this->createStub(ilObjUser::class);
38  $request = $this->createStub('Psr\Http\Message\RequestInterface');
39  $dav_factory = $this->createStub(ilWebDAVObjFactory::class);
40  $repository_helper = $this->createStub(ilWebDAVRepositoryHelper::class);
41 
42  $dav_container = new ilDAVContainer($object, $user, $request, $dav_factory, $repository_helper);
43 
44  $this->assertEquals('Some random Title', $dav_container->getName());
45  }

◆ testSetNameWithNonDavableNameThrowsForbiddenError()

ilDAVContainerTest::testSetNameWithNonDavableNameThrowsForbiddenError ( )

Definition at line 348 of file class.ilDAVContainerTest.php.

References Vendor\Package\$e, $ref_id, and getDAVContainerWithExpectationForFunctions().

348  : void
349  {
350  $ref_id = 7221;
351  $webdav_test_helper = new ilWebDAVTestHelper();
352  $tree = $webdav_test_helper->getTree();
353 
354  foreach ($tree['22']['children'] as $invalid_object) {
355  $dav_container = $this->getDAVContainerWithExpectationForFunctions($ref_id, 0, 0, 0);
356 
357  try {
358  $dav_container->setName($tree[$invalid_object]['title']);
359  $this->assertFalse('This should not happen!');
360  } catch (Forbidden $e) {
361  $this->assertEquals('Forbidden characters in title', $e->getMessage());
362  }
363  }
364  }
$ref_id
Definition: ltiauth.php:67
getDAVContainerWithExpectationForFunctions(int $object_ref_id, int $expects_object, int $expects_problem_info_file=0, int $expects_child_ref=1, bool $for_create=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ testSetNameWithoutPermissionsThrowsForbiddenError()

ilDAVContainerTest::testSetNameWithoutPermissionsThrowsForbiddenError ( )

Definition at line 334 of file class.ilDAVContainerTest.php.

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

334  : void
335  {
336  $parent_ref = 233563432;
337 
338  $dav_container = $this->getDAVContainerWithExpectationForFunctions($parent_ref, 0, 0, 0);
339 
340  try {
341  $dav_container->setName('My Valid Name');
342  $this->assertFalse('This should not happen!');
343  } catch (Forbidden $e) {
344  $this->assertEquals('Permission denied', $e->getMessage());
345  }
346  }
getDAVContainerWithExpectationForFunctions(int $object_ref_id, int $expects_object, int $expects_problem_info_file=0, int $expects_child_ref=1, bool $for_create=false)
+ Here is the call graph for this function:

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