ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
DirectoryNestingTest.php
Go to the documentation of this file.
1<?php
2
20
21use PHPUnit\Framework\MockObject\MockObject;
22
23require_once(__DIR__ . "/../AbstractTestBase.php");
24
30
36{
37 private const int NESTING_256 = 256; // 16^2
38 private const int NESTING_4096 = 4096; // 16^8
39 private const int NESTING_281474976710656 = 281_474_976_710_656;
40 private const int COMBINATIONS = 16; // 0-9a-f
44 protected MockObject $file_system_mock;
45
46 #[\Override]
47 protected function setUp(): void
48 {
49 parent::setUp();
50 $this->file_system_mock = $this->createMock(Filesystem::class);
51 }
52
53 private function withImplementation(StorageHandler $h, int $min, int $max): void
54 {
56
57 for ($x = 0; $x < 100; $x++) {
59 $path = $h->getContainerPathWithoutBase($random_id);
60 $path_elements = explode("/", $h->getContainerPathWithoutBase($random_id));
61 $first_element = end($path_elements);
62 $last_path_element = end($path_elements);
63 foreach ($path_elements as $path_element) {
64 $characters = strlen($path_element);
65 $possible_combinations = self::COMBINATIONS ** $characters;
66 if ($path_element !== $last_path_element) {
67 $this->assertLessThanOrEqual($max, $possible_combinations);
68 $this->assertGreaterThan($min, $possible_combinations);
69 }
70 }
71 }
72 }
73
74 public function testMaxNestingV1(): void
75 {
76 $storage_handler = new FileSystemStorageHandler($this->file_system_mock, 2);
77 $this->withImplementation($storage_handler, self::NESTING_256, self::NESTING_281474976710656);
78 }
79
80 public function testMaxNestingV2(): void
81 {
82 $storage_handler = new MaxNestingFileSystemStorageHandler($this->file_system_mock, 2);
83 $this->withImplementation($storage_handler, self::NESTING_4096 - 1, self::NESTING_4096);
84 }
85}
withImplementation(StorageHandler $h, int $min, int $max)
The filesystem interface provides the public interface for the Filesystem service API consumer.
Definition: Filesystem.php:37
getContainerPathWithoutBase(ResourceIdentification $identification)
This is only the path of a ResourceIdentification inside the StorageLocation base path.
$path
Definition: ltiservices.php:30
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...