19declare(strict_types=1);
23use PHPUnit\Framework\TestCase;
32 '.phpunit.result.cache',
33 'captainhook.local.json',
35 'phpstan-baseline.neon',
37 '.php-cs-fixer.cache',
49 'unzip_test_file.zip',
76 protected function setUp(): void
78 $this->ALLOWED_ROOT_FOLDER_DIRS = array_merge(
79 self::ALLOWED_ROOT_FOLDER_DIRS,
80 explode(
",", (
string) getenv(
'ALLOWED_ROOT_FOLDER_DIRS'))
82 $this->ALLOWED_ROOT_FOLDER_FILES = array_merge(
83 self::ALLOWED_ROOT_FOLDER_FILES,
84 explode(
",", (
string) getenv(
'ALLOWED_ROOT_FOLDER_FILES'))
90 $app_root_folder = __DIR__ .
"/../../../../";
92 if (!is_file($app_root_folder .
'/ilias_version.php')) {
93 $this->fail(
'Could not determine ILIAS root folder');
96 return $app_root_folder;
99 public function testAppRootFolderOnlyContainsDefinedFiles(): void
102 $iter = new \CallbackFilterIterator(
104 static function (\DirectoryIterator $file):
bool {
105 return $file->isFile();
108 foreach ($iter as $file) {
110 $found_files[] = $file->getBasename();
114 $unexpected_files = array_diff($found_files, $this->ALLOWED_ROOT_FOLDER_FILES);
119 'The following files are not expected in the ILIAS root folder: %s',
120 implode(
', ', $unexpected_files)
125 public function testAppRootFolderOnlyContainsDefinedFolders(): void
127 $found_directories = [];
128 $iter = new \CallbackFilterIterator(
130 static function (\DirectoryIterator $file):
bool {
131 return $file->isDir() && !$file->isDot();
134 foreach ($iter as $file) {
136 $found_directories[] = $file->getBasename();
139 $unexpected_directories = array_diff($found_directories, $this->ALLOWED_ROOT_FOLDER_DIRS);
140 sort($unexpected_directories);
143 $unexpected_directories,
145 'The following directories are not expected in the ILIAS root folder: %s',
146 implode(
', ', $unexpected_directories)
array $ALLOWED_ROOT_FOLDER_DIRS
const array ALLOWED_ROOT_FOLDER_DIRS
const array ALLOWED_ROOT_FOLDER_FILES
array $ALLOWED_ROOT_FOLDER_FILES