ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
PathGeneratorTest.php
Go to the documentation of this file.
1 <?php
2 
20 
27 
33 {
34  protected array $prohibited = [
35  "<", // (less than)
36  ">", // (greater than)
37  ":", // (colon - sometimes works, but is actually NTFS Alternate Data Streams)
38  "\"", // (double quote)
39  "\\", // (backslash)
40  "|", // (vertical bar or pipe)
41  "?", // (question mark)
42  "*", // (asterisk)
43  ];
44 
45  public function testPathGeneratorV1(): void
46  {
47  $identification_generator = new UniqueIDIdentificationGenerator();
48  $identification = $identification_generator->getUniqueResourceIdentification();
49 
50  $path_generator = new UUIDBasedPathGenerator();
51  $path = $path_generator->getPathFor($identification);
52  $this->assertGreaterThanOrEqual(strlen($identification->serialize()), strlen($path));
53  foreach ($this->prohibited as $value) {
54  $this->assertFalse(strpos($path, (string)$value));
55  }
56 
57  $new_identification = $path_generator->getIdentificationFor($path);
58  $this->assertEquals($identification->serialize(), $new_identification->serialize());
59  }
60 
61  public function testPathGeneratorV2(): void
62  {
63  $identification_generator = new UniqueIDIdentificationGenerator();
64  $identification = $identification_generator->getUniqueResourceIdentification();
65 
66  $path_generator = new MaxNestingPathGenerator();
67  $path = $path_generator->getPathFor($identification);
68 
69  foreach ($this->prohibited as $value) {
70  $this->assertFalse(strpos($path, (string)$value));
71  }
72 
73  $new_identification = $path_generator->getIdentificationFor($path);
74  $this->assertEquals($identification->serialize(), $new_identification->serialize());
75  }
76 }
$path
Definition: ltiservices.php:32
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...