ILIAS  release_7 Revision v7.30-3-g800a261c036
PathGeneratorTest.php
Go to the documentation of this file.
1<?php
2
4
7use ILIAS\ResourceStorage\StorageHandler\FSV1PathGenerator;
8use ILIAS\ResourceStorage\StorageHandler\FSV2PathGenerator;
11
17{
18
19 protected $prohibited = [
20 "<", // (less than)
21 ">", // (greater than)
22 ":", // (colon - sometimes works, but is actually NTFS Alternate Data Streams)
23 "\"", // (double quote)
24 "\\", // (backslash)
25 "|", // (vertical bar or pipe)
26 "?", // (question mark)
27 "*", // (asterisk)
28 ];
29
30 public function testPathGeneratorV1() : void
31 {
32 $identification_generator = new UniqueIDIdentificationGenerator();
33 $identification = $identification_generator->getUniqueResourceIdentification();
34
35 $path_generator = new UUIDBasedPathGenerator();
36 $path = $path_generator->getPathFor($identification);
37 $this->assertGreaterThanOrEqual(strlen($identification->serialize()), strlen($path));
38 foreach ($this->prohibited as $value) {
39 $this->assertFalse(strpos($path, $value));
40 }
41
42 $new_identification = $path_generator->getIdentificationFor($path);
43 $this->assertEquals($identification->serialize(), $new_identification->serialize());
44 }
45
46 public function testPathGeneratorV2() : void
47 {
48 $identification_generator = new UniqueIDIdentificationGenerator();
49 $identification = $identification_generator->getUniqueResourceIdentification();
50
51 $path_generator = new MaxNestingPathGenerator();
52 $path = $path_generator->getPathFor($identification);
53
54 foreach ($this->prohibited as $value) {
55 $this->assertFalse(strpos($path, $value));
56 }
57
58 $new_identification = $path_generator->getIdentificationFor($path);
59 $this->assertEquals($identification->serialize(), $new_identification->serialize());
60 }
61
62}
63
An exception for terminatinating execution or to throw for unit testing.