ILIAS  trunk Revision v11.0_alpha-1811-gd2d5443e411
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator 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 ()
 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 36 of file ilDAVContainerTest.php.

Member Function Documentation

◆ getChildrenTest()

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

Definition at line 245 of file ilDAVContainerTest.php.

References getDAVContainerWithExpectationForFunctions().

Referenced by testGetChilrendWithExistingNameOfFolderOrFileReturnsArrayOfObjects(), and testGetChilrendWithExistingNameOfFolderOrFileReturnsArrayWithProblemInfoFile().

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

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

◆ tearDown()

ilDAVContainerTest::tearDown ( )
protected

Definition at line 72 of file ilDAVContainerTest.php.

References $DIC, and $dic.

72  : void
73  {
74  global $DIC;
75 
76  $DIC = $this->dic;
77 
78  parent::tearDown();
79  }
global $DIC
Definition: shib_login.php:22

◆ testChildExistsWithExistingNameOfFolderOrFileReturnsTrue()

ilDAVContainerTest::testChildExistsWithExistingNameOfFolderOrFileReturnsTrue ( )

Definition at line 279 of file ilDAVContainerTest.php.

References $ref_id, and getDAVContainerWithExpectationForFunctions().

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

References $ref_id, and getDAVContainerWithExpectationForFunctions().

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

References $ref_id, and getDAVContainerWithExpectationForFunctions().

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

References $ref_id, and getDAVContainerWithExpectationForFunctions().

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

References $ref_id, and getDAVContainerWithExpectationForFunctions().

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

References $ref_id, and getDAVContainerWithExpectationForFunctions().

353  : void
354  {
355  $ref_id = 7;
356  $name = 'None existent name';
357 
358  $dav_container = $this->getDAVContainerWithExpectationForFunctions(
359  $ref_id,
360  7
361  );
362 
363  $this->assertFalse($dav_container->childExists($name));
364  }
$ref_id
Definition: ltiauth.php:65
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 453 of file ilDAVContainerTest.php.

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

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

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

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

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

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

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

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

References $ref_id, and getDAVContainerWithExpectationForFunctions().

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

References $ref_id, and getDAVContainerWithExpectationForFunctions().

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

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

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

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

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

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

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

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

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

References $ref_id, and getChildrenTest().

214  : void
215  {
216  $ref_id = 23356343;
217  $additional_information = [
218  'names' => ['Last First Child', 'Last Last Child'],
219  'classes' => [ilDAVContainer::class, ilDAVFile::class],
220  'ref_id' => ['233563432', '2335634323356343'],
221  'expects_objects' => 4,
222  'expects_problem_info_file' => 0
223  ];
224 
225  $this->getChildrenTest($ref_id, $additional_information);
226  }
getChildrenTest(int $ref_id, array $additional_information)
$ref_id
Definition: ltiauth.php:65
+ Here is the call graph for this function:

◆ testGetChilrendWithExistingNameOfFolderOrFileReturnsArrayWithProblemInfoFile()

ilDAVContainerTest::testGetChilrendWithExistingNameOfFolderOrFileReturnsArrayWithProblemInfoFile ( )

Definition at line 228 of file ilDAVContainerTest.php.

References $ref_id, and getChildrenTest().

228  : void
229  {
230  $ref_id = 7;
231  $additional_information = [
232  'names' => ['Second First Child', 'Second Second Child', 'Second Fourth Child', 'Problem Info File'],
233  'classes' => [ilDAVFile::class, ilDAVFile::class, ilDAVContainer::class, ilDAVProblemInfoFile::class],
234  'ref_id' => ['72', '78', '7221', '7222'],
235  'expects_objects' => 7,
236  'expects_problem_info_file' => 1,
237  ];
238 
239  $this->getChildrenTest($ref_id, $additional_information);
240  }
getChildrenTest(int $ref_id, array $additional_information)
$ref_id
Definition: ltiauth.php:65
+ Here is the call graph for this function:

◆ testGetNameGetsObjectTitle()

ilDAVContainerTest::testGetNameGetsObjectTitle ( )

Definition at line 81 of file ilDAVContainerTest.php.

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

◆ testSetNameWithNonDavableNameThrowsForbiddenError()

ilDAVContainerTest::testSetNameWithNonDavableNameThrowsForbiddenError ( )

Definition at line 403 of file ilDAVContainerTest.php.

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

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

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

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

Referenced by tearDown().


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