ILIAS  release_8 Revision v8.24
DirectoryNestingTest.php
Go to the documentation of this file.
1<?php
2
20
26
32{
33 private const NESTING_256 = 256; // 16^2
34 private const NESTING_4096 = 4096; // 16^3
35 private const NESTING_65536 = 65536; // 16^4
36 private const NESTING_4294967296 = 4_294_967_296; // 16^8
37 private const NESTING_281474976710656 = 281_474_976_710_656; // 16^12
38
41 private const COMBINATIONS = 16; // 0-9a-f
42
47
48 protected function setUp(): void
49 {
50 parent::setUp();
51 $this->file_system_mock = $this->createMock(Filesystem::class);
52 }
53
54 private function withImplementation(StorageHandler $h, int $min, int $max): void
55 {
57
58 for ($x = 0; $x < 100; $x++) {
59 $random_id = $id_generator->getUniqueResourceIdentification();
60 $path = $h->getContainerPathWithoutBase($random_id);
61 $path_elements = explode("/", $h->getContainerPathWithoutBase($random_id));
62 $first_element = end($path_elements);
63 $last_path_element = end($path_elements);
64 foreach ($path_elements as $path_element) {
65 $characters = strlen($path_element);
66 $possible_combinations = self::COMBINATIONS ** $characters;
67 if ($path_element !== $last_path_element) {
68 $this->assertLessThanOrEqual($max, $possible_combinations);
69 $this->assertGreaterThan($min, $possible_combinations);
70 }
71 }
72 }
73 }
74
75 public function testMaxNestingV1(): void
76 {
77 $storage_handler = new FileSystemStorageHandler($this->file_system_mock, 2);
78 $this->withImplementation($storage_handler, self::NESTING_256, self::NESTING_281474976710656);
79 }
80
81 public function testMaxNestingV2(): void
82 {
83 $storage_handler = new MaxNestingFileSystemStorageHandler($this->file_system_mock, 2);
84 $this->withImplementation($storage_handler, self::NESTING_4096 - 1, self::NESTING_4096);
85 }
86}
ILIAS ResourceStorage DummyIDGenerator $id_generator
withImplementation(StorageHandler $h, int $min, int $max)
Interface Filesystem.
Definition: Filesystem.php:40
getContainerPathWithoutBase(ResourceIdentification $identification)
This is only the path of a ResourceIdentification inside the StorageLocation base path.
$path
Definition: ltiservices.php:32
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...