ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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 ()
 disabled More...
 
 testDeleteWithoutPermissionsThrowsForbiddenError ()
 

Protected Member Functions

 tearDown ()
 
 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)
 

Protected Attributes

Container $dic = null
 

Detailed Description

Definition at line 35 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 243 of file class.ilDAVContainerTest.php.

References getDAVContainerWithExpectationForFunctions().

Referenced by testGetChilrendWithExistingNameOfFolderOrFileReturnsArrayOfObjects(), and testGetChilrendWithExistingNameOfFolderOrFileReturnsArrayWithProblemInfoFile().

243  : void
244  {
245  $dav_container = $this->getDAVContainerWithExpectationForFunctions(
246  $ref_id,
247  $additional_information['expects_objects'],
248  $additional_information['expects_problem_info_file']
249  );
250  $children = $dav_container->getChildren();
251  $this->assertEquals(count($additional_information['names']), count($children));
252  for ($i = 0, $i_max = count($children); $i < $i_max; $i++) {
253  $this->assertInstanceOf(
254  $additional_information['classes'][$i],
255  $children[$additional_information['ref_id'][$i]]
256  );
257  $this->assertEquals(
258  $additional_information['names'][$i],
259  $children[$additional_information['ref_id'][$i]]->getName()
260  );
261  }
262  }
$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:
+ 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 484 of file class.ilDAVContainerTest.php.

References $ref_id, 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().

490  : ilDAVContainer {
491  $object_folder = new ilObjFolder();
492  $object_folder->setRefId($object_ref_id);
493  $user = $this->createStub(ilObjUser::class);
494  $request = $this->createStub(RequestInterface::class);
495 
496  $webdav_test_helper = new ilWebDAVTestHelper();
497  $tree = $webdav_test_helper->getTree();
498 
499  $mocked_dav_factory = $this->createPartialMock(
500  ilWebDAVObjFactory::class,
501  ['retrieveDAVObjectByRefID', 'getProblemInfoFile']
502  );
503  $mocked_dav_factory->expects($this->exactly($expects_object))
504  ->method('retrieveDAVObjectByRefID')->willReturnCallback(
505  function (int $ref_id) use ($tree): INode {
506  if ($tree[$ref_id]['access'] === 'none') {
507  throw new Forbidden("No read permission for object with reference ID $ref_id");
508  }
509 
510  if ($tree[$ref_id]['type'] === 'fold') {
511  $obj_class = ilDAVContainer::class;
512  } elseif ($tree[$ref_id]['type'] === 'file') {
513  $obj_class = ilDAVFile::class;
514  } else {
516  }
517 
518  if ($this->hasTitleForbiddenChars($tree[$ref_id]['title'])) {
520  }
521 
522  if ($this->isHiddenFile($tree[$ref_id]['title'])) {
524  }
525 
526  $object = $this->createMock($obj_class);
527  $object->expects($this->atMost(3))->method('getName')->willReturn($tree[$ref_id]['title']);
528  return $object;
529  }
530  );
531  $mocked_dav_factory->expects($this->exactly($expects_problem_info_file))
532  ->method('getProblemInfoFile')->willReturnCallback(
533  function (int $ref_id): ilDAVProblemInfoFile {
534  $problem_info_file = $this->createMock(ilDAVProblemInfoFile::class);
535  $problem_info_file->expects($this->atMost(2))->method('getName')->willReturn('Problem Info File');
536  return $problem_info_file;
537  }
538  );
539 
540  $mocked_repo_helper = $this->createPartialMock(
541  ilWebDAVRepositoryHelper::class,
542  ['getChildrenOfRefId', 'checkcreateAccessForType', 'checkAccess']
543  );
544  $mocked_repo_helper->expects($this->exactly($expects_child_ref))
545  ->method('getChildrenOfRefId')->willReturnCallback(
546  fn(int $parent_ref): array => $tree[$parent_ref]['children']
547  );
548  $mocked_repo_helper->expects($this->atMost(1))
549  ->method('checkcreateAccessForType')->willReturnCallback(
550  fn($parent_ref, $type): bool => $tree[$parent_ref]['access'] === 'write'
551  );
552  $mocked_repo_helper->expects($this->atMost(1))
553  ->method('checkAccess')->willReturnCallback(
554  fn(string $permission, int $ref_id): bool => in_array(
555  $permission,
556  ['write', 'delete']
557  ) && $tree[$ref_id]['access'] === 'write'
558  );
559 
560  if ($for_create) {
561  $object_child = new ilObjFolder();
562  $object_child->setType('fold');
564  $object_folder,
565  $user,
566  $request,
567  $mocked_dav_factory,
568  $mocked_repo_helper
569  );
570  $dav_container->setChildcollection($object_child);
571  return $dav_container;
572  }
573 
574  return new ilDAVContainer($object_folder, $user, $request, $mocked_dav_factory, $mocked_repo_helper);
575  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ref_id
Definition: ltiauth.php:67
+ Here is the caller graph for this function:

◆ tearDown()

ilDAVContainerTest::tearDown ( )
protected

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

References $DIC, and $dic.

70  : void
71  {
72  global $DIC;
73 
74  $DIC = $this->dic;
75 
76  parent::tearDown();
77  }
global $DIC
Definition: feed.php:28

◆ testChildExistsWithExistingNameOfFolderOrFileReturnsTrue()

ilDAVContainerTest::testChildExistsWithExistingNameOfFolderOrFileReturnsTrue ( )

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

References $ref_id, and getDAVContainerWithExpectationForFunctions().

277  : void
278  {
279  $ref_ids = [
280  '7' => [
281  'name' => 'Second Fourth Child',
282  'expects_objects' => 6
283  ],
284  '23356343' => [
285  'name' => 'Last Last Child',
286  'expects_objects' => 4
287  ]
288  ];
289 
290  foreach ($ref_ids as $ref_id => $additional_information) {
291  $dav_container = $this->getDAVContainerWithExpectationForFunctions(
292  (int) $ref_id,
293  $additional_information['expects_objects']
294  );
295  $this->assertTrue($dav_container->childExists($additional_information['name']));
296  }
297  }
$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 299 of file class.ilDAVContainerTest.php.

References $ref_id, and getDAVContainerWithExpectationForFunctions().

299  : void
300  {
301  $ref_id = 7;
302  $additional_information = [
303  'name' => 'Second Second Child',
304  'expects_objects' => 4
305  ];
306 
307  $dav_container = $this->getDAVContainerWithExpectationForFunctions(
308  $ref_id,
309  $additional_information['expects_objects']
310  );
311  $this->assertTrue($dav_container->childExists($additional_information['name']));
312  }
$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 329 of file class.ilDAVContainerTest.php.

References $ref_id, and getDAVContainerWithExpectationForFunctions().

329  : void
330  {
331  $ref_ids = [
332  '7' => [
333  'name' => 'Second Third Child',
334  'expects_objects' => 7
335  ],
336  '23356343' => [
337  'name' => 'Last Third Child',
338  'expects_objects' => 4
339  ]
340  ];
341 
342  foreach ($ref_ids as $ref_id => $additional_information) {
343  $dav_container = $this->getDAVContainerWithExpectationForFunctions(
344  (int) $ref_id,
345  $additional_information['expects_objects']
346  );
347  $this->assertFalse($dav_container->childExists($additional_information['name']));
348  }
349  }
$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 364 of file class.ilDAVContainerTest.php.

References $ref_id, and getDAVContainerWithExpectationForFunctions().

364  : void
365  {
366  $ref_ids = [
367  '7' => [
368  'name' => 'Second Last Child',
369  'expects_objects' => 7
370  ],
371  '23356343' => [
372  'name' => 'Last Second Child',
373  'expects_objects' => 4
374  ]
375  ];
376 
377  foreach ($ref_ids as $ref_id => $additional_information) {
378  $dav_container = $this->getDAVContainerWithExpectationForFunctions(
379  (int) $ref_id,
380  $additional_information['expects_objects']
381  );
382 
383  $this->assertFalse($dav_container->childExists($additional_information['name']));
384  }
385  }
$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 314 of file class.ilDAVContainerTest.php.

References $ref_id, and getDAVContainerWithExpectationForFunctions().

314  : void
315  {
316  $ref_id = '22';
317  $webdav_test_helper = new ilWebDAVTestHelper();
318  $tree = $webdav_test_helper->getTree();
319 
320  foreach ($tree[$ref_id]['children'] as $child_ref) {
321  $dav_container = $this->getDAVContainerWithExpectationForFunctions(
322  (int) $ref_id,
323  11
324  );
325  $this->assertFalse($dav_container->childExists($tree[$child_ref]['title']));
326  }
327  }
$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:

◆ testChildExistsWithNonExistentNameOfFolderOrFileReturnsFalse()

ilDAVContainerTest::testChildExistsWithNonExistentNameOfFolderOrFileReturnsFalse ( )

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

References $ref_id, and getDAVContainerWithExpectationForFunctions().

351  : void
352  {
353  $ref_id = 7;
354  $name = 'None existent name';
355 
356  $dav_container = $this->getDAVContainerWithExpectationForFunctions(
357  $ref_id,
358  7
359  );
360 
361  $this->assertFalse($dav_container->childExists($name));
362  }
$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 ( )

disabled

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

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

451  : void
452  {
453  define('ILIAS_LOG_ENABLED', false);
454  $ref_id = 7221;
455  $webdav_test_helper = new ilWebDAVTestHelper();
456  $tree = $webdav_test_helper->getTree();
457 
458  foreach ($tree['22']['children'] as $invalid_object) {
459  $dav_container = $this->getDAVContainerWithExpectationForFunctions($ref_id, 0, 0, 0, true);
460 
461  try {
462  $dav_container->createDirectory($tree[$invalid_object]['title']);
463  $this->assertFalse('This should not happen!');
464  } catch (Forbidden $e) {
465  $this->assertEquals('Forbidden characters in title', $e->getMessage());
466  }
467  }
468  }
$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:

◆ testCreateDirectoryWithoutPermissionsThrowsForbiddenError()

ilDAVContainerTest::testCreateDirectoryWithoutPermissionsThrowsForbiddenError ( )

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

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

433  : void
434  {
435  $parent_ref = 233563432;
436 
437  $dav_container = $this->getDAVContainerWithExpectationForFunctions($parent_ref, 0, 0, 0, true);
438 
439  try {
440  $dav_container->createDirectory('My New Folder');
441  $this->assertFalse('This should not happen!');
442  } catch (Forbidden $e) {
443  $this->assertEquals('Permission denied', $e->getMessage());
444  }
445  }
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 419 of file class.ilDAVContainerTest.php.

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

419  : void
420  {
421  $parent_ref = 233563432;
422 
423  $dav_container = $this->getDAVContainerWithExpectationForFunctions($parent_ref, 0, 0, 0, false);
424 
425  try {
426  $dav_container->createFile('My New File.txt');
427  $this->assertFalse('This should not happen!');
428  } catch (Forbidden $e) {
429  $this->assertEquals('Permission denied', $e->getMessage());
430  }
431  }
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 470 of file class.ilDAVContainerTest.php.

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

470  : void
471  {
472  $parent_ref = 233563432;
473 
474  $dav_container = $this->getDAVContainerWithExpectationForFunctions($parent_ref, 0, 0, 0);
475 
476  try {
477  $dav_container->delete();
478  $this->assertFalse('This should not happen!');
479  } catch (Forbidden $e) {
480  $this->assertEquals('Permission denied', $e->getMessage());
481  }
482  }
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 264 of file class.ilDAVContainerTest.php.

References $ref_id, and getDAVContainerWithExpectationForFunctions().

264  : void
265  {
266  $ref_id = 22;
267 
268  $dav_container = $this->getDAVContainerWithExpectationForFunctions(
269  $ref_id,
270  11,
271  1
272  );
273  $children = $dav_container->getChildren();
274  $this->assertEquals(1, count($children));
275  }
$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 94 of file class.ilDAVContainerTest.php.

References $ref_id, and getDAVContainerWithExpectationForFunctions().

94  : void
95  {
96  $ref_ids = [
97  '7' => [
98  'name' => 'Second Fourth Child',
99  'class' => ilDAVContainer::class,
100  'expects_objects' => 7
101  ],
102  '23356343' => [
103  'name' => 'Last Last Child',
104  'class' => ilDAVFile::class,
105  'expects_objects' => 4
106  ]
107  ];
108 
109  foreach ($ref_ids as $ref_id => $additional_information) {
110  $dav_container = $this->getDAVContainerWithExpectationForFunctions(
111  (int) $ref_id,
112  $additional_information['expects_objects']
113  );
114  $object = $dav_container->getChild($additional_information['name']);
115  $this->assertInstanceOf($additional_information['class'], $object);
116  $this->assertEquals($additional_information['name'], $object->getName());
117  }
118  }
$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 141 of file class.ilDAVContainerTest.php.

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

141  : void
142  {
143  $ref_ids = [
144  '7' => [
145  'name' => 'Second Third Child',
146  'expects_objects' => 7
147  ],
148  '23356343' => [
149  'name' => 'Last Third Child',
150  'expects_objects' => 4
151  ]
152  ];
153 
154  foreach ($ref_ids as $ref_id => $additional_information) {
155  try {
156  $dav_container = $this->getDAVContainerWithExpectationForFunctions(
157  (int) $ref_id,
158  $additional_information['expects_objects']
159  );
160  $dav_container->getChild($additional_information['name']);
161  $this->assertFalse('This should not happen');
162  } catch (NotFound $e) {
163  $this->assertEquals($additional_information['name'] . ' not found', $e->getMessage());
164  }
165  }
166  }
$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 185 of file class.ilDAVContainerTest.php.

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

185  : void
186  {
187  $ref_ids = [
188  '7' => [
189  'name' => 'Second Last Child',
190  'expects_objects' => 7
191  ],
192  '23356343' => [
193  'name' => 'Last Second Child',
194  'expects_objects' => 4
195  ]
196  ];
197 
198  foreach ($ref_ids as $ref_id => $additional_information) {
199  try {
200  $dav_container = $this->getDAVContainerWithExpectationForFunctions(
201  (int) $ref_id,
202  $additional_information['expects_objects']
203  );
204  $dav_container->getChild($additional_information['name']);
205  $this->assertFalse('This should not happen');
206  } catch (NotFound $e) {
207  $this->assertEquals($additional_information['name'] . ' not found', $e->getMessage());
208  }
209  }
210  }
$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 120 of file class.ilDAVContainerTest.php.

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

120  : void
121  {
122  $ref_id = '22';
123  $webdav_test_helper = new ilWebDAVTestHelper();
124  $tree = $webdav_test_helper->getTree();
125 
126  foreach ($tree[$ref_id]['children'] as $child_ref) {
127  $dav_container = $this->getDAVContainerWithExpectationForFunctions(
128  (int) $ref_id,
129  11
130  );
131  try {
132  $dav_container->getChild($tree[$child_ref]['title']);
133  $this->assertFalse('This should never happen');
134  } catch (NotFound $e) {
135  $this->assertEquals($tree[$child_ref]['title'] . ' not found', $e->getMessage());
136  ;
137  }
138  }
139  }
$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:

◆ testGetChildWithNonExistentNameOfFolderOrFileThrowsNotFoundError()

ilDAVContainerTest::testGetChildWithNonExistentNameOfFolderOrFileThrowsNotFoundError ( )

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

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

168  : void
169  {
170  $ref_id = 7;
171  $name = 'None existent name';
172 
173  try {
174  $dav_container = $this->getDAVContainerWithExpectationForFunctions(
175  $ref_id,
176  7
177  );
178  $dav_container->getChild($name);
179  $this->assertFalse('This should not happen');
180  } catch (NotFound $e) {
181  $this->assertEquals("$name not found", $e->getMessage());
182  }
183  }
$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 212 of file class.ilDAVContainerTest.php.

References $ref_id, and getChildrenTest().

212  : void
213  {
214  $ref_id = 23356343;
215  $additional_information = [
216  'names' => ['Last First Child', 'Last Last Child'],
217  'classes' => [ilDAVContainer::class, ilDAVFile::class],
218  'ref_id' => ['233563432', '2335634323356343'],
219  'expects_objects' => 4,
220  'expects_problem_info_file' => 0
221  ];
222 
223  $this->getChildrenTest($ref_id, $additional_information);
224  }
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 226 of file class.ilDAVContainerTest.php.

References $ref_id, and getChildrenTest().

226  : void
227  {
228  $ref_id = 7;
229  $additional_information = [
230  'names' => ['Second First Child', 'Second Second Child', 'Second Fourth Child', 'Problem Info File'],
231  'classes' => [ilDAVFile::class, ilDAVFile::class, ilDAVContainer::class, ilDAVProblemInfoFile::class],
232  'ref_id' => ['72', '78', '7221', '7222'],
233  'expects_objects' => 7,
234  'expects_problem_info_file' => 1,
235  ];
236 
237  $this->getChildrenTest($ref_id, $additional_information);
238  }
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 79 of file class.ilDAVContainerTest.php.

79  : void
80  {
81  $object = $this->createMock(ilObjFolder::class);
82  $object->expects($this->once())->method('getTitle')->willReturn('Some random Title');
83 
84  $user = $this->createStub(ilObjUser::class);
85  $request = $this->createStub(RequestInterface::class);
86  $dav_factory = $this->createStub(ilWebDAVObjFactory::class);
87  $repository_helper = $this->createStub(ilWebDAVRepositoryHelper::class);
88 
89  $dav_container = new ilDAVContainer($object, $user, $request, $dav_factory, $repository_helper);
90 
91  $this->assertEquals('Some random Title', $dav_container->getName());
92  }

◆ testSetNameWithNonDavableNameThrowsForbiddenError()

ilDAVContainerTest::testSetNameWithNonDavableNameThrowsForbiddenError ( )

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

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

401  : void
402  {
403  $ref_id = 7221;
404  $webdav_test_helper = new ilWebDAVTestHelper();
405  $tree = $webdav_test_helper->getTree();
406 
407  foreach ($tree['22']['children'] as $invalid_object) {
408  $dav_container = $this->getDAVContainerWithExpectationForFunctions($ref_id, 0, 0, 0);
409 
410  try {
411  $dav_container->setName($tree[$invalid_object]['title']);
412  $this->assertFalse('This should not happen!');
413  } catch (Forbidden $e) {
414  $this->assertEquals('Forbidden characters in title', $e->getMessage());
415  }
416  }
417  }
$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:

◆ testSetNameWithoutPermissionsThrowsForbiddenError()

ilDAVContainerTest::testSetNameWithoutPermissionsThrowsForbiddenError ( )

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

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

387  : void
388  {
389  $parent_ref = 233563432;
390 
391  $dav_container = $this->getDAVContainerWithExpectationForFunctions($parent_ref, 0, 0, 0);
392 
393  try {
394  $dav_container->setName('My Valid Name');
395  $this->assertFalse('This should not happen!');
396  } catch (Forbidden $e) {
397  $this->assertEquals('Permission denied', $e->getMessage());
398  }
399  }
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:

Field Documentation

◆ $dic

Container ilDAVContainerTest::$dic = null
protected

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

Referenced by tearDown().


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