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