ILIAS  trunk Revision v11.0_alpha-2645-g16283d3b3f8
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

 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 246 of file ilDAVContainerTest.php.

References getDAVContainerWithExpectationForFunctions().

Referenced by testGetChilrendWithExistingNameOfFolderOrFileReturnsArrayOfObjects(), and testGetChilrendWithExistingNameOfFolderOrFileReturnsArrayWithProblemInfoFile().

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

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

◆ tearDown()

ilDAVContainerTest::tearDown ( )
protected

Definition at line 73 of file ilDAVContainerTest.php.

References $DIC, and $dic.

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

◆ testChildExistsWithExistingNameOfFolderOrFileReturnsTrue()

ilDAVContainerTest::testChildExistsWithExistingNameOfFolderOrFileReturnsTrue ( )

Definition at line 280 of file ilDAVContainerTest.php.

References $ref_id, and getDAVContainerWithExpectationForFunctions().

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

References $ref_id, and getDAVContainerWithExpectationForFunctions().

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

References $ref_id, and getDAVContainerWithExpectationForFunctions().

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

References $ref_id, and getDAVContainerWithExpectationForFunctions().

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

References $ref_id, and getDAVContainerWithExpectationForFunctions().

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

References $ref_id, and getDAVContainerWithExpectationForFunctions().

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

Definition at line 452 of file ilDAVContainerTest.php.

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

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

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

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

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

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

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

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

References $ref_id, and getDAVContainerWithExpectationForFunctions().

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

References $ref_id, and getDAVContainerWithExpectationForFunctions().

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

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

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

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

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

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

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

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

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

References $ref_id, and getChildrenTest().

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

References $ref_id, and getChildrenTest().

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

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

◆ testSetNameWithNonDavableNameThrowsForbiddenError()

ilDAVContainerTest::testSetNameWithNonDavableNameThrowsForbiddenError ( )

Definition at line 404 of file ilDAVContainerTest.php.

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

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

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

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