‪TYPO3CMS  10.4
LocalDriverTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use org\bovigo\vfs\vfsStream;
32 
37 {
41  protected ‪$resetSingletonInstances = true;
42 
46  protected ‪$backupEnvironment = true;
47 
51  protected ‪$localDriver;
52 
56  protected ‪$testDirs = [];
57 
61  protected ‪$iso88591GreaterThan127 = '';
62 
66  protected ‪$utf8Latin1Supplement = '';
67 
71  protected ‪$utf8Latin1ExtendedA = '';
72 
76  protected function ‪tearDown(): void
77  {
78  foreach ($this->testDirs as ‪$dir) {
79  chmod(‪$dir, 0777);
81  }
82  parent::tearDown();
83  }
84 
93  protected function ‪createRealTestdir(): string
94  {
96  mkdir(‪$basedir);
97  $this->testDirs[] = ‪$basedir;
98  return ‪$basedir;
99  }
100 
107  protected function ‪prepareRealTestEnvironment(): array
108  {
110  $subject = $this->‪createDriver([
111  'basePath' => ‪$basedir
112  ]);
113  return [‪$basedir, $subject];
114  }
115 
125  protected function ‪createDriver(array $driverConfiguration = [], array $mockedDriverMethods = []): ‪LocalDriver
126  {
127  // it's important to do that here, so vfsContents could have been set before
128  if (!isset($driverConfiguration['basePath'])) {
129  $this->‪initializeVfs();
130  $driverConfiguration['basePath'] = $this->‪getMountRootUrl();
131  }
133  $mockedDriverMethods[] = 'isPathValid';
134  $driver = $this->getAccessibleMock(
135  LocalDriver::class,
136  $mockedDriverMethods,
137  [$driverConfiguration]
138  );
139  $driver->expects(self::any())
140  ->method('isPathValid')
141  ->willReturn(
142  true
143  );
144 
145  $driver->setStorageUid(5);
146  $driver->processConfiguration();
147  $driver->initialize();
148  return $driver;
149  }
150 
154  public function ‪calculatedBasePathRelativeIsSane(): void
155  {
156  $subject = $this->‪createDriver();
157 
158  // This would cause problems if you fill "/fileadmin/" into the base path field of a sys_file_storage record and select "relative" as path type
159  $relativeDriverConfiguration = [
160  'pathType' => 'relative',
161  'basePath' => '/typo3temp/var/tests/',
162  ];
163  $basePath = $subject->_call('calculateBasePath', $relativeDriverConfiguration);
164 
165  self::assertStringNotContainsString('//', $basePath);
166  }
167 
171  public function ‪calculatedBasePathAbsoluteIsSane(): void
172  {
173  $subject = $this->‪createDriver();
174 
175  // This test checks if "/../" are properly filtered out (i.e. from "Base path" field of sys_file_storage)
176  $varPath = ‪Environment::getVarPath();
177  $projectPath = ‪Environment::getProjectPath();
178  $relativeVarPath = str_replace($projectPath, '', $varPath);
179  $segments = str_repeat('/..', substr_count($relativeVarPath, '/') + 1);
180  $relativeDriverConfiguration = [
181  'basePath' => ‪Environment::getVarPath() . '/tests' . $segments . $relativeVarPath . '/tests/',
182  ];
183  $basePath = $subject->_call('calculateBasePath', $relativeDriverConfiguration);
184 
185  self::assertStringNotContainsString('/../', $basePath);
186  }
187 
189  {
190  return [
191  'no base uri, within public' => [
192  '/files/',
193  '',
194  '/foo.txt',
195  true,
196  'files/foo.txt',
197  ],
198  'no base uri, within project' => [
199  '/../files/',
200  '',
201  '/foo.txt',
202  false,
203  null,
204  ],
205  'base uri with host, within public' => [
206  '/files/',
207  'https://host.tld/',
208  '/foo.txt',
209  true,
210  'https://host.tld/foo.txt',
211  ],
212  'base uri with host, within project' => [
213  '/../files/',
214  'https://host.tld/',
215  '/foo.txt',
216  true,
217  'https://host.tld/foo.txt',
218  ],
219  'base uri with path only, within public' => [
220  '/files/',
221  'assets/',
222  '/foo.txt',
223  true,
224  'assets/foo.txt',
225  ],
226  'base uri with path only, within project' => [
227  '/../files/',
228  'assets/',
229  '/foo.txt',
230  true,
231  'assets/foo.txt',
232  ],
233  'base uri with path only, within other public dir' => [
234  '/../public/assets/',
235  'assets/',
236  '/foo.txt',
237  true,
238  'assets/foo.txt',
239  ],
240  ];
241  }
242 
252  public function ‪publicUrlIsCalculatedCorrectlyWithDifferentBasePathsAndBasUris(string $basePath, string $baseUri, string $fileName, bool $expectedIsPublic, ?string $expectedPublicUrl): void
253  {
254  $testDir = $this->‪createRealTestdir();
255  $projectPath = $testDir . '/app';
256  $publicPath = $projectPath . '/public';
257  $absoluteBaseDir = $publicPath . $basePath;
258  mkdir($projectPath);
259  mkdir($publicPath);
260  mkdir($absoluteBaseDir, 0777, true);
263  true,
264  false,
265  $projectPath,
266  $publicPath,
270  ‪Environment::isUnix() ? 'UNIX' : 'WINDOWS'
271  );
272  $driverConfiguration = [
273  'pathType' => 'relative',
274  'basePath' => $basePath,
275  'baseUri' => $baseUri,
276  ];
277 
278  $subject = $this->‪createDriver($driverConfiguration);
279 
280  self::assertSame($expectedIsPublic, $subject->hasCapability(‪ResourceStorageInterface::CAPABILITY_PUBLIC));
281  self::assertSame($fileName, $subject->createFile($fileName, '/'));
282  self::assertSame($expectedPublicUrl, $subject->getPublicUrl($fileName));
283  }
284 
288  public function ‪createFolderRecursiveSanitizesFilename(): void
289  {
291  $driver = $this->‪createDriver([], ['sanitizeFilename']);
292  $driver->expects(self::exactly(2))
293  ->method('sanitizeFileName')
294  ->willReturn(
295  'sanitized'
296  );
297  $driver->createFolder('newFolder/andSubfolder', '/', true);
298  self::assertFileExists($this->‪getUrlInMount('/sanitized/sanitized/'));
299  }
300 
304  public function ‪determineBaseUrlUrlEncodesUriParts(): void
305  {
307  $driver = $this->getAccessibleMock(
308  LocalDriver::class,
309  ['hasCapability'],
310  [],
311  '',
312  false
313  );
314  $driver->expects(self::once())
315  ->method('hasCapability')
317  ->willReturn(
318  true
319  );
320  $driver->_set('absoluteBasePath', ‪Environment::getPublicPath() . '/un encö/ded %path/');
321  $driver->_call('determineBaseUrl');
322  $baseUri = $driver->_get('baseUri');
323  self::assertEquals(rawurlencode('un encö') . '/' . rawurlencode('ded %path') . '/', $baseUri);
324  }
325 
330  {
331  $subject = $this->‪createDriver();
332  $folderIdentifier = $subject->getDefaultFolder();
333  self::assertEquals('/user_upload/', $folderIdentifier);
334  }
335 
340  {
341  $subject = $this->‪createDriver();
342  self::assertFileExists($this->‪getUrlInMount($subject->getDefaultFolder()));
343  }
344 
348  public function ‪getFolderInFolderReturnsCorrectFolderObject(): void
349  {
350  $this->‪addToMount([
351  'someDir' => [
352  'someSubdir' => []
353  ]
354  ]);
355  $subject = $this->‪createDriver();
356  $folder = $subject->getFolderInFolder('someSubdir', '/someDir/');
357  self::assertEquals('/someDir/someSubdir/', $folder);
358  }
359 
363  public function ‪createFolderCreatesFolderOnDisk(): void
364  {
365  $this->‪addToMount(['some' => ['folder' => []]]);
366  $subject = $this->‪createDriver();
367  $subject->createFolder('path', '/some/folder/');
368  self::assertFileExists($this->‪getUrlInMount('/some/folder/'));
369  self::assertFileExists($this->‪getUrlInMount('/some/folder/path'));
370  }
371 
375  public function ‪createFolderReturnsFolderObject(): void
376  {
377  $this->‪addToMount(['some' => ['folder' => []]]);
378  $subject = $this->‪createDriver();
379  $createdFolder = $subject->createFolder('path', '/some/folder/');
380  self::assertEquals('/some/folder/path/', $createdFolder);
381  }
382 
387  {
388  return [
389  'folder name with NULL character' => [
390  'some' . "\0" . 'Folder',
391  'some_Folder'
392  ],
393  'folder name with directory part' => [
394  '../someFolder',
395  '.._someFolder'
396  ]
397  ];
398  }
399 
406  public function ‪createFolderSanitizesFolderNameBeforeCreation(string $newFolderName, string $expectedFolderName): void
407  {
408  $this->‪addToMount(['some' => ['folder' => []]]);
409  $subject = $this->‪createDriver();
410  $subject->createFolder($newFolderName, '/some/folder/');
411  self::assertFileExists($this->‪getUrlInMount('/some/folder/' . $expectedFolderName));
412  }
413 
417  public function ‪basePathIsNormalizedWithTrailingSlash(): void
418  {
419  $subject = $this->‪createDriver();
420  self::assertEquals('/', substr($subject->_call('getAbsoluteBasePath'), -1));
421  }
422 
427  {
428  $subject = $this->‪createDriver();
429  self::assertNotEquals('/', substr($subject->_call('getAbsoluteBasePath'), -2, 1));
430  }
431 
435  public function ‪getSpecificFileInformationDataProvider(): array
436  {
437  return [
438  'size' => [
439  'expectedValue' => filesize(__DIR__ . '/Fixtures/Dummy.html'),
440  'propertyName' => 'size'
441  ],
442  'atime' => [
443  'expectedValue' => 'WILL_BE_REPLACED_BY_VFS_TIME',
444  'propertyName' => 'atime'
445  ],
446  'mtime' => [
447  'expectedValue' => 'WILL_BE_REPLACED_BY_VFS_TIME',
448  'propertyName' => 'mtime'
449  ],
450  'ctime' => [
451  'expectedValue' => 'WILL_BE_REPLACED_BY_VFS_TIME',
452  'propertyName' => 'ctime'
453  ],
454  'name' => [
455  'expectedValue' => 'Dummy.html',
456  'propertyName' => 'name'
457  ],
458  'mimetype' => [
459  'expectedValue' => 'text/html',
460  'propertyName' => 'mimetype'
461  ],
462  'identifier' => [
463  'expectedValue' => '/Dummy.html',
464  'propertyName' => 'identifier'
465  ],
466  'storage' => [
467  'expectedValue' => 5,
468  'propertyName' => 'storage'
469  ],
470  'identifier_hash' => [
471  'expectedValue' => 'b11efa5d7c0556a65c6aa261343b9807cac993bc',
472  'propertyName' => 'identifier_hash'
473  ],
474  'folder_hash' => [
475  'expectedValue' => '42099b4af021e53fd8fd4e056c2568d7c2e3ffa8',
476  'propertyName' => 'folder_hash'
477  ]
478  ];
479  }
480 
487  public function ‪getSpecificFileInformationReturnsRequestedFileInformation($expectedValue, string $property): void
488  {
489  $root = vfsStream::setup('root');
490 
491  $subFolder = vfsStream::newDirectory('fileadmin');
492  $root->addChild($subFolder);
493 
494  // Load fixture files and folders from disk
495  $directory = vfsStream::copyFromFileSystem(__DIR__ . '/Fixtures/', $subFolder, 1024 * 1024);
496  if (in_array($property, ['mtime', 'ctime', 'atime'])) {
497  $expectedValue = $directory->getChild('Dummy.html')->filemtime();
498  }
499 
500  $subject = $this->‪createDriver(['basePath' => 'vfs://root/fileadmin']);
501  self::assertSame(
502  $expectedValue,
503  $subject->getSpecificFileInformation('vfs://root/fileadmin/Dummy.html', '/', $property)
504  );
505  }
506 
510  public function ‪getAbsolutePathReturnsCorrectPath(): void
511  {
512  $this->‪addToMount([
513  'someFolder' => [
514  'file1.ext' => 'asdfg'
515  ]
516  ]);
517  $subject = $this->‪createDriver();
518  $path = $subject->_call('getAbsolutePath', '/someFolder/file1.ext');
519  self::assertTrue(file_exists($path));
520  self::assertEquals($this->‪getUrlInMount('/someFolder/file1.ext'), $path);
521  }
522 
526  public function ‪addFileMovesFileToCorrectLocation(): void
527  {
528  $this->‪addToMount(['targetFolder' => []]);
529  $this->‪addToVfs([
530  'sourceFolder' => [
531  'file' => 'asdf'
532  ]
533  ]);
534  $subject = $this->‪createDriver(
535  [],
536  ['getMimeTypeOfFile']
537  );
538  self::assertTrue(file_exists($this->‪getUrl('sourceFolder/file')));
539  $subject->addFile($this->‪getUrl('sourceFolder/file'), '/targetFolder/', 'file');
540  self::assertTrue(file_exists($this->‪getUrlInMount('/targetFolder/file')));
541  }
542 
546  public function ‪addFileUsesFilenameIfGiven(): void
547  {
548  $this->‪addToMount(['targetFolder' => []]);
549  $this->‪addToVfs([
550  'sourceFolder' => [
551  'file' => 'asdf'
552  ]
553  ]);
554  $subject = $this->‪createDriver(
555  [],
556  ['getMimeTypeOfFile']
557  );
558  self::assertTrue(file_exists($this->‪getUrl('sourceFolder/file')));
559  $subject->addFile($this->‪getUrl('sourceFolder/file'), '/targetFolder/', 'targetFile');
560  self::assertTrue(file_exists($this->‪getUrlInMount('/targetFolder/targetFile')));
561  }
562 
566  public function ‪addFileFailsIfFileIsInDriverStorage(): void
567  {
568  $this->expectException(\InvalidArgumentException::class);
569  $this->expectExceptionCode(1314778269);
570  $this->‪addToMount([
571  'targetFolder' => [
572  'file' => 'asdf'
573  ]
574  ]);
575  $subject = $this->‪createDriver();
576  $subject->addFile($this->‪getUrlInMount('/targetFolder/file'), '/targetFolder/', 'file');
577  }
578 
582  public function ‪addFileReturnsFileIdentifier(): void
583  {
584  $this->‪addToMount(['targetFolder' => []]);
585  $this->‪addToVfs([
586  'sourceFolder' => [
587  'file' => 'asdf'
588  ]
589  ]);
590  $subject = $this->‪createDriver(
591  [],
592  ['getMimeTypeOfFile']
593  );
594  self::assertTrue(file_exists($this->‪getUrl('sourceFolder/file')));
595  $fileIdentifier = $subject->addFile($this->‪getUrl('sourceFolder/file'), '/targetFolder/', 'file');
596  self::assertEquals('file', basename($fileIdentifier));
597  self::assertEquals('/targetFolder/file', $fileIdentifier);
598  }
599 
603  public function ‪existenceChecksWorkForFilesAndFolders(): void
604  {
605  $this->‪addToMount([
606  'file' => 'asdf',
607  'folder' => []
608  ]);
609  $subject = $this->‪createDriver();
610  // Using slashes at the beginning of paths because they will be stored in the DB this way.
611  self::assertTrue($subject->fileExists('/file'));
612  self::assertTrue($subject->folderExists('/folder/'));
613  self::assertFalse($subject->fileExists('/nonexistingFile'));
614  self::assertFalse($subject->folderExists('/nonexistingFolder/'));
615  }
616 
621  {
622  $this->‪addToMount([
623  'subfolder' => [
624  'file' => 'asdf',
625  'folder' => []
626  ]
627  ]);
628  $subject = $this->‪createDriver();
629  self::assertTrue($subject->fileExistsInFolder('file', '/subfolder/'));
630  self::assertTrue($subject->folderExistsInFolder('folder', '/subfolder/'));
631  self::assertFalse($subject->fileExistsInFolder('nonexistingFile', '/subfolder/'));
632  self::assertFalse($subject->folderExistsInFolder('nonexistingFolder', '/subfolder/'));
633  }
634 
639  {
640  $baseUri = 'http://example.org/foobar/' . ‪StringUtility::getUniqueId('uri_');
641  $this->‪addToMount([
642  'file.ext' => 'asdf',
643  'subfolder' => [
644  'file2.ext' => 'asdf'
645  ]
646  ]);
647  $subject = $this->‪createDriver([
648  'baseUri' => $baseUri
649  ]);
650  self::assertEquals($baseUri . '/file.ext', $subject->getPublicUrl('/file.ext'));
651  self::assertEquals($baseUri . '/subfolder/file2.ext', $subject->getPublicUrl('/subfolder/file2.ext'));
652  }
653 
660  {
661  return [
662  ['/single file with some special chars äüö!.txt'],
663  ['/on subfolder/with special chars äüö!.ext'],
664  ['/who names a file like !"§$%&()=?*+~"#\'´`<>-.ext'],
665  ['no leading slash !"§$%&()=?*+~#\'"´`"<>-.txt']
666  ];
667  }
668 
674  public function ‪getPublicUrlReturnsValidUrlContainingSpecialCharacters(string $fileIdentifier): void
675  {
676  $baseUri = 'http://example.org/foobar/' . ‪StringUtility::getUniqueId('uri_');
677  $subject = $this->‪createDriver([
678  'baseUri' => $baseUri
679  ]);
680  $publicUrl = $subject->getPublicUrl($fileIdentifier);
681  self::assertTrue(
682  ‪GeneralUtility::isValidUrl($publicUrl),
683  'getPublicUrl did not return a valid URL:' . $publicUrl
684  );
685  }
686 
690  public function ‪fileContentsCanBeWrittenAndRead(): void
691  {
692  $fileContents = 'asdf';
693  $this->‪addToMount([
694  'file.ext' => $fileContents
695  ]);
696  $subject = $this->‪createDriver();
697  self::assertEquals($fileContents, $subject->getFileContents('/file.ext'), 'File contents could not be read');
698  $newFileContents = 'asdfgh';
699  $subject->setFileContents('/file.ext', $newFileContents);
700  self::assertEquals(
701  $newFileContents,
702  $subject->getFileContents('/file.ext'),
703  'New file contents could not be read.'
704  );
705  }
706 
711  {
712  $fileContents = 'asdf';
713  $this->‪addToMount([
714  'file.ext' => $fileContents
715  ]);
716  $subject = $this->‪createDriver();
717  $newFileContents = 'asdfgh';
718  $bytesWritten = $subject->setFileContents('/file.ext', $newFileContents);
719  self::assertEquals(strlen($newFileContents), $bytesWritten);
720  }
721 
726  public function ‪newFilesCanBeCreated(): void
727  {
728  $subject = $this->‪createDriver();
729  $subject->createFile('testfile.txt', '/');
730  self::assertTrue($subject->fileExists('/testfile.txt'));
731  }
732 
737  public function ‪createdFilesAreEmpty(): void
738  {
739  $subject = $this->‪createDriver();
740  $subject->createFile('testfile.txt', '/');
741  self::assertTrue($subject->fileExists('/testfile.txt'));
742  $fileData = $subject->getFileContents('/testfile.txt');
743  self::assertEquals(0, strlen($fileData));
744  }
745 
749  public function ‪createFileFixesPermissionsOnCreatedFile(): void
750  {
752  self::markTestSkipped('createdFilesHaveCorrectRights() tests not available on Windows');
753  }
754 
755  // No one will use this as his default file create mask so we hopefully don't get any false positives
756  $testpattern = '0646';
757  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask'] = $testpattern;
758 
759  $this->‪addToMount(
760  [
761  'someDir' => []
762  ]
763  );
765  [‪$basedir, $subject] = $this->‪prepareRealTestEnvironment();
766  mkdir(‪$basedir . '/someDir');
767  $subject->createFile('testfile.txt', '/someDir');
768  self::assertEquals((int)$testpattern, (int)(decoct(fileperms(‪$basedir . '/someDir/testfile.txt') & 0777)));
769  }
770 
771  /**********************************
772  * File and directory listing
773  **********************************/
777  public function ‪getFileReturnsCorrectIdentifier(): void
778  {
779  $root = vfsStream::setup('root');
780  $subFolder = vfsStream::newDirectory('fileadmin');
781  $root->addChild($subFolder);
782  // Load fixture files and folders from disk
783  vfsStream::copyFromFileSystem(__DIR__ . '/Fixtures/', $subFolder, 1024 * 1024);
784 
785  $subject = $this->‪createDriver(['basePath' => 'vfs://root/fileadmin']);
786 
787  $subdirFileInfo = $subject->getFileInfoByIdentifier('Dummy.html');
788  self::assertEquals('/Dummy.html', $subdirFileInfo['identifier']);
789  $rootFileInfo = $subject->getFileInfoByIdentifier('LocalDriverFilenameFilter.php');
790  self::assertEquals('/LocalDriverFilenameFilter.php', $rootFileInfo['identifier']);
791  }
792 
796  public function ‪getFileThrowsExceptionIfFileDoesNotExist(): void
797  {
798  $this->expectException(\InvalidArgumentException::class);
799  $this->expectExceptionCode(1314516809);
800  $subject = $this->‪createDriver();
801  $subject->getFileInfoByIdentifier('/some/file/at/a/random/path');
802  }
803 
808  {
809  $subject = $this->‪createDriver();
810  $fileList = $subject->getFilesInFolder('/');
811  self::assertEmpty($fileList);
812  }
813 
817  public function ‪getFileListReturnsAllFilesInDirectory(): void
818  {
819  $dirStructure = [
820  'aDir' => [],
821  'file1' => 'asdfg',
822  'file2' => 'fdsa'
823  ];
824  $this->‪addToMount($dirStructure);
825  $subject = $this->‪createDriver(
826  [],
827  // Mocked because finfo() can not deal with vfs streams and throws warnings
828  ['getMimeTypeOfFile']
829  );
830  $fileList = $subject->getFilesInFolder('/');
831  self::assertEquals(['/file1', '/file2'], array_keys($fileList));
832  }
833 
838  {
839  $dirStructure = [
840  'aDir' => [
841  'file3' => 'asdfgh',
842  'subdir' => [
843  'file4' => 'asklfjklasjkl'
844  ]
845  ],
846  'file1' => 'asdfg',
847  'file2' => 'fdsa'
848  ];
849  $this->‪addToMount($dirStructure);
850  $subject = $this->‪createDriver(
851  [],
852  // Mocked because finfo() can not deal with vfs streams and throws warnings
853  ['getMimeTypeOfFile']
854  );
855  $fileList = $subject->getFilesInFolder('/', 0, 0, true);
856  self::assertEquals(['/file1', '/file2', '/aDir/file3', '/aDir/subdir/file4'], array_keys($fileList));
857  }
858 
862  public function ‪getFileListFailsIfDirectoryDoesNotExist(): void
863  {
864  $this->expectException(\InvalidArgumentException::class);
865  $this->expectExceptionCode(1314349666);
866  $this->‪addToMount(['somefile' => '']);
867  $subject = $this->‪createDriver();
868  $subject->getFilesInFolder('somedir/');
869  }
870 
875  {
876  $dirStructure = [
877  'file2' => 'fdsa'
878  ];
879  // register static callback to self
880  $callback = [
881  [
882  static::class,
883  'callbackStaticTestFunction'
884  ]
885  ];
886  $this->‪addToMount($dirStructure);
887  $subject = $this->‪createDriver();
888  // the callback function will throw an exception used to check if it was called with correct $itemName
889  $this->expectException(\InvalidArgumentException::class);
890  $this->expectExceptionCode(1336159604);
891  $subject->getFilesInFolder('/', 0, 0, false, $callback);
892  }
893 
903  public static function ‪callbackStaticTestFunction(string $itemName): void
904  {
905  if ($itemName === 'file2') {
906  throw new \InvalidArgumentException('$itemName', 1336159604);
907  }
908  }
909 
914  {
915  $dirStructure = [
916  'fileA' => 'asdfg',
917  'fileB' => 'fdsa'
918  ];
919  $this->‪addToMount($dirStructure);
920  $subject = $this->‪createDriver(
921  [],
922  // Mocked because finfo() can not deal with vfs streams and throws warnings
923  ['getMimeTypeOfFile']
924  );
925  $filterCallbacks = [
926  [
927  LocalDriverFilenameFilter::class,
928  'filterFilename',
929  ],
930  ];
931  $fileList = $subject->getFilesInFolder('/', 0, 0, false, $filterCallbacks);
932  self::assertNotContains('/fileA', array_keys($fileList));
933  }
934 
939  {
940  $dirStructure = [
941  'dir1' => [],
942  'dir2' => [],
943  'file' => 'asdfg'
944  ];
945  $this->‪addToMount($dirStructure);
946  $subject = $this->‪createDriver();
947  $fileList = $subject->getFoldersInFolder('/');
948  self::assertEquals(['/dir1/', '/dir2/'], array_keys($fileList));
949  }
950 
954  public function ‪getFolderListReturnsHiddenFoldersByDefault(): void
955  {
956  $dirStructure = [
957  '.someHiddenDir' => [],
958  'aDir' => [],
959  'file1' => ''
960  ];
961  $this->‪addToMount($dirStructure);
962  $subject = $this->‪createDriver();
963 
964  $fileList = $subject->getFoldersInFolder('/');
965 
966  self::assertEquals(['/.someHiddenDir/', '/aDir/'], array_keys($fileList));
967  }
968 
974  public function ‪getFolderListLeavesOutNavigationalEntries(): void
975  {
976  // we have to add .. and . manually, as these are not included in vfsStream directory listings (as opposed
977  // to normal filelistings)
978  $this->‪addToMount([
979  '..' => [],
980  '.' => []
981  ]);
982  $subject = $this->‪createDriver();
983  $fileList = $subject->getFoldersInFolder('/');
984  self::assertEmpty($fileList);
985  }
986 
991  {
992  $dirStructure = [
993  'folderA' => [],
994  'folderB' => []
995  ];
996  $this->‪addToMount($dirStructure);
997  $subject = $this->‪createDriver();
998  $filterCallbacks = [
999  [
1000  LocalDriverFilenameFilter::class,
1001  'filterFilename',
1002  ],
1003  ];
1004  $folderList = $subject->getFoldersInFolder('/', 0, 0, $filterCallbacks);
1005  self::assertNotContains('folderA', array_keys($folderList));
1006  }
1007 
1011  public function ‪getFolderListFailsIfDirectoryDoesNotExist(): void
1012  {
1013  $this->expectException(\InvalidArgumentException::class);
1014  $this->expectExceptionCode(1314349666);
1015  $subject = $this->‪createDriver();
1016  vfsStream::create([$this->basedir => ['somefile' => '']]);
1017  $subject->getFoldersInFolder('somedir/');
1018  }
1019 
1023  public function ‪hashReturnsCorrectHashes(): void
1024  {
1025  $contents = '68b329da9893e34099c7d8ad5cb9c940';
1026  $expectedMd5Hash = '8c67dbaf0ba22f2e7fbc26413b86051b';
1027  $expectedSha1Hash = 'a60cd808ba7a0bcfa37fa7f3fb5998e1b8dbcd9d';
1028  $this->‪addToMount(['hashFile' => $contents]);
1029  $subject = $this->‪createDriver();
1030  self::assertEquals($expectedSha1Hash, $subject->hash('/hashFile', 'sha1'));
1031  self::assertEquals($expectedMd5Hash, $subject->hash('/hashFile', 'md5'));
1032  }
1033 
1037  public function ‪hashingWithUnsupportedAlgorithmFails(): void
1038  {
1039  $this->expectException(\InvalidArgumentException::class);
1040  $this->expectExceptionCode(1304964032);
1041  $subject = $this->‪createDriver();
1042  $subject->hash('/hashFile', ‪StringUtility::getUniqueId('uri_'));
1043  }
1044 
1050  {
1051  $fileContents = 'asdfgh';
1052  $this->‪addToMount([
1053  'someDir' => [
1054  'someFile' => $fileContents
1055  ]
1056  ]);
1057  $subject = $this->‪createDriver([], ['copyFileToTemporaryPath']);
1058  $subject->expects(self::once())->method('copyFileToTemporaryPath');
1059  $subject->getFileForLocalProcessing('/someDir/someFile');
1060  }
1061 
1066  {
1067  $fileContents = 'asdfgh';
1068  $this->‪addToMount([
1069  'someDir' => [
1070  'someFile' => $fileContents
1071  ]
1072  ]);
1073  $subject = $this->‪createDriver();
1074  $filePath = $subject->getFileForLocalProcessing('/someDir/someFile', false);
1075  self::assertEquals($filePath, $this->‪getUrlInMount('someDir/someFile'));
1076  }
1077 
1081  public function ‪filesCanBeCopiedToATemporaryPath(): void
1082  {
1083  $fileContents = 'asdfgh';
1084  $this->‪addToMount([
1085  'someDir' => [
1086  'someFile.ext' => $fileContents
1087  ]
1088  ]);
1089  $subject = $this->‪createDriver();
1090  $filePath = GeneralUtility::fixWindowsFilePath($subject->_call('copyFileToTemporaryPath', '/someDir/someFile.ext'));
1091  $this->testFilesToDelete[] = $filePath;
1092  self::assertStringContainsString(‪Environment::getVarPath() . '/transient/', $filePath);
1093  self::assertEquals($fileContents, file_get_contents($filePath));
1094  }
1095 
1100  {
1102  [‪$basedir, $subject] = $this->‪prepareRealTestEnvironment();
1103  touch(‪$basedir . '/someFile');
1104  chmod(‪$basedir . '/someFile', 448);
1105  clearstatcache();
1106  self::assertEquals(['r' => true, 'w' => true], $subject->getPermissions('/someFile'));
1107  }
1108 
1113  {
1114  if (\function_exists('posix_getegid') && posix_getegid() === 0) {
1115  self::markTestSkipped('Test skipped if run on linux as root');
1116  } elseif (‪Environment::isWindows()) {
1117  self::markTestSkipped('Test skipped if run on Windows system');
1118  }
1120  [‪$basedir, $subject] = $this->‪prepareRealTestEnvironment();
1121  touch(‪$basedir . '/someForbiddenFile');
1122  chmod(‪$basedir . '/someForbiddenFile', 0);
1123  clearstatcache();
1124  self::assertEquals(['r' => false, 'w' => false], $subject->getPermissions('/someForbiddenFile'));
1125  }
1126 
1131  {
1133  [‪$basedir, $subject] = $this->‪prepareRealTestEnvironment();
1134  mkdir(‪$basedir . '/someFolder');
1135  chmod(‪$basedir . '/someFolder', 448);
1136  clearstatcache();
1137  self::assertEquals(['r' => true, 'w' => true], $subject->getPermissions('/someFolder'));
1138  }
1139 
1144  {
1145  if (function_exists('posix_getegid') && posix_getegid() === 0) {
1146  self::markTestSkipped('Test skipped if run on linux as root');
1147  } elseif (‪Environment::isWindows()) {
1148  self::markTestSkipped('Test skipped if run on Windows system');
1149  }
1151  [‪$basedir, $subject] = $this->‪prepareRealTestEnvironment();
1152  mkdir(‪$basedir . '/someForbiddenFolder');
1153  chmod(‪$basedir . '/someForbiddenFolder', 0);
1154  clearstatcache();
1155  $result = $subject->getPermissions('/someForbiddenFolder');
1156  // Change permissions back to writable, so the sub-folder can be removed in tearDown
1157  chmod(‪$basedir . '/someForbiddenFolder', 0777);
1158  self::assertEquals(['r' => false, 'w' => false], $result);
1159  }
1160 
1165  {
1166  $subject = $this->‪createDriver();
1167  self::assertTrue($subject->isWithin('/someFolder/', '/someFolder/test.jpg'));
1168  self::assertTrue($subject->isWithin('/someFolder/', '/someFolder/subFolder/test.jpg'));
1169  self::assertFalse($subject->isWithin('/someFolder/', '/someFolderWithALongName/test.jpg'));
1170  }
1171 
1175  public function ‪isWithinAcceptsFileAndFolderObjectsAsContent(): void
1176  {
1177  $subject = $this->‪createDriver();
1178  self::assertTrue($subject->isWithin('/someFolder/', '/someFolder/test.jpg'));
1179  self::assertTrue($subject->isWithin('/someFolder/', '/someFolder/subfolder/'));
1180  }
1181 
1182  /**********************************
1183  * Copy/move file
1184  **********************************/
1185 
1189  public function ‪filesCanBeCopiedWithinStorage(): void
1190  {
1191  $fileContents = ‪StringUtility::getUniqueId('content_');
1192  $this->‪addToMount([
1193  'someFile' => $fileContents,
1194  'targetFolder' => []
1195  ]);
1196  $subject = $this->‪createDriver(
1197  [],
1198  ['getMimeTypeOfFile']
1199  );
1200  $subject->copyFileWithinStorage('/someFile', '/targetFolder/', 'someFile');
1201  self::assertFileEquals($this->‪getUrlInMount('/someFile'), $this->‪getUrlInMount('/targetFolder/someFile'));
1202  }
1203 
1207  public function ‪filesCanBeMovedWithinStorage(): void
1208  {
1209  $fileContents = ‪StringUtility::getUniqueId('content_');
1210  $this->‪addToMount([
1211  'targetFolder' => [],
1212  'someFile' => $fileContents
1213  ]);
1214  $subject = $this->‪createDriver();
1215  $newIdentifier = $subject->moveFileWithinStorage('/someFile', '/targetFolder/', 'file');
1216  self::assertEquals($fileContents, file_get_contents($this->‪getUrlInMount('/targetFolder/file')));
1217 
1218  // @todo remove condition and else branch as soon as phpunit v8 goes out of support
1219  if (method_exists($this, 'assertFileDoesNotExist')) {
1220  self::assertFileDoesNotExist($this->‪getUrlInMount('/someFile'));
1221  } else {
1222  self::assertFileNotExists($this->‪getUrlInMount('/someFile'));
1223  }
1225  self::assertEquals('/targetFolder/file', $newIdentifier);
1226  }
1227 
1231  public function ‪fileMetadataIsChangedAfterMovingFile(): void
1232  {
1233  $fileContents = ‪StringUtility::getUniqueId('content_');
1234  $this->‪addToMount([
1235  'targetFolder' => [],
1236  'someFile' => $fileContents
1237  ]);
1238  $subject = $this->‪createDriver(
1239  [],
1240  // Mocked because finfo() can not deal with vfs streams and throws warnings
1241  ['getMimeTypeOfFile']
1242  );
1243  $newIdentifier = $subject->moveFileWithinStorage('/someFile', '/targetFolder/', 'file');
1244  $fileMetadata = $subject->getFileInfoByIdentifier($newIdentifier);
1245  self::assertEquals($newIdentifier, $fileMetadata['identifier']);
1246  }
1247 
1248  public function ‪renamingFiles_dataProvider(): array
1249  {
1250  return [
1251  'file in subfolder' => [
1252  [
1253  'targetFolder' => ['file' => '']
1254  ],
1255  '/targetFolder/file',
1256  'newFile',
1257  '/targetFolder/newFile'
1258  ],
1259  'file in rootfolder' => [
1260  [
1261  'fileInRoot' => ''
1262  ],
1263  '/fileInRoot',
1264  'newFile',
1265  '/newFile'
1266  ]
1267  ];
1268  }
1269 
1278  public function ‪renamingFilesChangesFilenameOnDisk(array $filesystemStructure, string $oldFileIdentifier, string $newFileName, string $expectedNewIdentifier)
1279  {
1280  $this->‪addToMount($filesystemStructure);
1281  $subject = $this->‪createDriver();
1282  $newIdentifier = $subject->renameFile($oldFileIdentifier, $newFileName);
1283  self::assertFalse($subject->fileExists($oldFileIdentifier));
1284  self::assertTrue($subject->fileExists($newIdentifier));
1285  self::assertEquals($expectedNewIdentifier, $newIdentifier);
1286  }
1287 
1291  public function ‪renamingFilesFailsIfTargetFileExists(): void
1292  {
1293  $this->expectException(ExistingTargetFileNameException::class);
1294  $this->expectExceptionCode(1320291063);
1295  $this->‪addToMount([
1296  'targetFolder' => ['file' => '', 'newFile' => '']
1297  ]);
1298  $subject = $this->‪createDriver();
1299  $subject->renameFile('/targetFolder/file', 'newFile');
1300  }
1301 
1307  public function ‪renamingFolders_dataProvider(): array
1308  {
1309  return [
1310  'folder in root folder' => [
1311  [
1312  'someFolder' => []
1313  ],
1314  '/someFolder/',
1315  'newFolder',
1316  '/newFolder/'
1317  ],
1318  'file in subfolder' => [
1319  [
1320  'subfolder' => [
1321  'someFolder' => []
1322  ]
1323  ],
1324  '/subfolder/someFolder/',
1325  'newFolder',
1326  '/subfolder/newFolder/'
1327  ]
1328  ];
1329  }
1330 
1340  array $filesystemStructure,
1341  string $oldFolderIdentifier,
1342  string $newFolderName,
1343  string $expectedNewIdentifier
1344  ): void {
1345  $this->‪addToMount($filesystemStructure);
1346  $subject = $this->‪createDriver();
1347  $mapping = $subject->renameFolder($oldFolderIdentifier, $newFolderName);
1348  self::assertFalse($subject->folderExists($oldFolderIdentifier));
1349  self::assertTrue($subject->folderExists($expectedNewIdentifier));
1350  self::assertEquals($expectedNewIdentifier, $mapping[$oldFolderIdentifier]);
1351  }
1352 
1357  {
1358  $fileContents = 'asdfg';
1359  $this->‪addToMount([
1360  'sourceFolder' => [
1361  'subFolder' => ['file' => $fileContents],
1362  'file2' => 'asdfg'
1363  ]
1364  ]);
1365  $subject = $this->‪createDriver();
1366  $mappingInformation = $subject->renameFolder('/sourceFolder/', 'newFolder');
1367  self::assertTrue(is_array($mappingInformation));
1368  self::assertEquals('/newFolder/', $mappingInformation['/sourceFolder/']);
1369  self::assertEquals('/newFolder/file2', $mappingInformation['/sourceFolder/file2']);
1370  self::assertEquals('/newFolder/subFolder/file', $mappingInformation['/sourceFolder/subFolder/file']);
1371  self::assertEquals('/newFolder/subFolder/', $mappingInformation['/sourceFolder/subFolder/']);
1372  }
1373 
1378  {
1379  $this->expectException(\RuntimeException::class);
1380  $this->expectExceptionCode(1334160746);
1381  $this->‪addToMount([
1382  'sourceFolder' => [
1383  'file' => 'asdfg'
1384  ]
1385  ]);
1386  $subject = $this->‪createDriver([], ['createIdentifierMap']);
1387  $subject->expects(self::atLeastOnce())->method('createIdentifierMap')->will(
1388  self::throwException(
1389  new ‪FileOperationErrorException('testing', 1476045666)
1390  )
1391  );
1392  $subject->renameFolder('/sourceFolder/', 'newFolder');
1393  self::assertFileExists($this->‪getUrlInMount('/sourceFolder/file'));
1394  }
1395 
1400  {
1401  // This also prepares the next few tests, so add more info than required for this test
1402  $this->‪addToMount([
1403  'emptyFolder' => []
1404  ]);
1405  $subject = $this->‪createDriver();
1406  self::assertTrue($subject->isFolderEmpty('/emptyFolder/'));
1407  return $subject;
1408  }
1409 
1413  public function ‪isFolderEmptyReturnsFalseIfFolderHasFile(): void
1414  {
1415  $this->‪addToMount([
1416  'folderWithFile' => [
1417  'someFile' => ''
1418  ]
1419  ]);
1420  $subject = $this->‪createDriver();
1421  self::assertFalse($subject->isFolderEmpty('/folderWithFile/'));
1422  }
1423 
1427  public function ‪isFolderEmptyReturnsFalseIfFolderHasSubfolder(): void
1428  {
1429  $this->‪addToMount([
1430  'folderWithSubfolder' => [
1431  'someFolder' => []
1432  ]
1433  ]);
1434  $subject = $this->‪createDriver();
1435  self::assertFalse($subject->isFolderEmpty('/folderWithSubfolder/'));
1436  }
1438  /**********************************
1439  * Copy/move folder
1440  **********************************/
1444  public function ‪foldersCanBeMovedWithinStorage(): void
1445  {
1446  $fileContents = ‪StringUtility::getUniqueId('content_');
1447  $this->‪addToMount([
1448  'sourceFolder' => [
1449  'file' => $fileContents,
1450  ],
1451  'targetFolder' => [],
1452  ]);
1453  $subject = $this->‪createDriver();
1455  $subject->moveFolderWithinStorage('/sourceFolder/', '/targetFolder/', 'someFolder');
1456  self::assertTrue(file_exists($this->‪getUrlInMount('/targetFolder/someFolder/')));
1457  self::assertEquals($fileContents, file_get_contents($this->‪getUrlInMount('/targetFolder/someFolder/file')));
1458  // @todo remove condition and else branch as soon as phpunit v8 goes out of support
1459  if (method_exists($this, 'assertFileDoesNotExist')) {
1460  self::assertFileDoesNotExist($this->‪getUrlInMount('/sourceFolder'));
1461  } else {
1462  self::assertFileNotExists($this->‪getUrlInMount('/sourceFolder'));
1463  }
1464  }
1465 
1470  {
1471  $fileContents = 'asdfg';
1472  $this->‪addToMount([
1473  'targetFolder' => [],
1474  'sourceFolder' => [
1475  'subFolder' => ['file' => $fileContents],
1476  'file' => 'asdfg'
1477  ]
1478  ]);
1479  $subject = $this->‪createDriver();
1480  $mappingInformation = $subject->moveFolderWithinStorage('/sourceFolder/', '/targetFolder/', 'sourceFolder');
1481  self::assertEquals('/targetFolder/sourceFolder/file', $mappingInformation['/sourceFolder/file']);
1482  self::assertEquals(
1483  '/targetFolder/sourceFolder/subFolder/file',
1484  $mappingInformation['/sourceFolder/subFolder/file']
1485  );
1486  self::assertEquals('/targetFolder/sourceFolder/subFolder/', $mappingInformation['/sourceFolder/subFolder/']);
1487  }
1488 
1492  public function ‪folderCanBeRenamedWhenMoving(): void
1493  {
1494  $this->‪addToMount([
1495  'sourceFolder' => [
1496  'file' => ‪StringUtility::getUniqueId('content_'),
1497  ],
1498  'targetFolder' => [],
1499  ]);
1500  $subject = $this->‪createDriver();
1501  $subject->moveFolderWithinStorage('/sourceFolder/', '/targetFolder/', 'newFolder');
1502  self::assertTrue(file_exists($this->‪getUrlInMount('/targetFolder/newFolder/')));
1503  }
1504 
1509  {
1510  $this->‪addToMount([
1511  'sourceFolder' => [
1512  'file' => ‪StringUtility::getUniqueId('name_'),
1513  ],
1514  'targetFolder' => [],
1515  ]);
1516  $subject = $this->‪createDriver();
1517  $subject->copyFolderWithinStorage('/sourceFolder/', '/targetFolder/', 'newFolderName');
1518  self::assertTrue(is_file($this->‪getUrlInMount('/targetFolder/newFolderName/file')));
1519  }
1520 
1525  {
1526  [$basePath, $subject] = $this->‪prepareRealTestEnvironment();
1527  ‪GeneralUtility::mkdir_deep($basePath . '/sourceFolder/subFolder');
1528  ‪GeneralUtility::mkdir_deep($basePath . '/targetFolder');
1529 
1530  $subject->copyFolderWithinStorage('/sourceFolder/', '/targetFolder/', 'newFolderName');
1531  self::assertTrue(is_dir($basePath . '/targetFolder/newFolderName/subFolder'));
1532  }
1533 
1538  {
1539  [$basePath, $subject] = $this->‪prepareRealTestEnvironment();
1540  ‪GeneralUtility::mkdir_deep($basePath . '/sourceFolder/subFolder');
1541  ‪GeneralUtility::mkdir_deep($basePath . '/targetFolder');
1542  file_put_contents($basePath . '/sourceFolder/subFolder/file', ‪StringUtility::getUniqueId('content_'));
1543  ‪GeneralUtility::fixPermissions($basePath . '/sourceFolder/subFolder/file');
1544 
1545  $subject->copyFolderWithinStorage('/sourceFolder/', '/targetFolder/', 'newFolderName');
1546  self::assertTrue(is_file($basePath . '/targetFolder/newFolderName/subFolder/file'));
1547  }
1548 
1550  // Tests concerning sanitizeFileName
1552 
1556  public function ‪setUpCharacterStrings(): void
1557  {
1558  // Generate string containing all characters for the iso8859-1 charset, charcode greater than 127
1559  $this->iso88591GreaterThan127 = '';
1560  for ($i = 0xA0; $i <= 0xFF; $i++) {
1561  $this->iso88591GreaterThan127 .= chr($i);
1562  }
1563 
1564  // Generate string containing all characters for the utf-8 Latin-1 Supplement (U+0080 to U+00FF)
1565  // without U+0080 to U+009F: control characters
1566  // Based on http://www.utf8-chartable.de/unicode-utf8-table.pl
1567  $this->utf8Latin1Supplement = '';
1568  for ($i = 0xA0; $i <= 0xBF; $i++) {
1569  $this->utf8Latin1Supplement .= chr(0xC2) . chr($i);
1570  }
1571  for ($i = 0x80; $i <= 0xBF; $i++) {
1572  $this->utf8Latin1Supplement .= chr(0xC3) . chr($i);
1573  }
1574 
1575  // Generate string containing all characters for the utf-8 Latin-1 Extended-A (U+0100 to U+017F)
1576  $this->utf8Latin1ExtendedA = '';
1577  for ($i = 0x80; $i <= 0xBF; $i++) {
1578  $this->utf8Latin1ExtendedA .= chr(0xC4) . chr($i);
1579  }
1580  for ($i = 0x80; $i <= 0xBF; $i++) {
1581  $this->utf8Latin1ExtendedA .= chr(0xC5) . chr($i);
1582  }
1583  }
1584 
1595  public function ‪sanitizeFileNameUTF8FilesystemDataProvider(): array
1596  {
1597  $this->‪setUpCharacterStrings();
1598  return [
1599  // Characters ordered by ASCII table
1600  'allowed characters utf-8 (ASCII part)' => [
1601  '-.0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz',
1602  '-.0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz'
1603  ],
1604  // Characters ordered by ASCII table (except for space-character, because space-character ist trimmed)
1605  'replace special characters with _ (not allowed characters) utf-8 (ASCII part)' => [
1606  '! "#$%&\'()*+,/:;<=>?[\\]^`{|}~',
1607  '_____________________________'
1608  ],
1609  'utf-8 (Latin-1 Supplement)' => [
1611  '________________________________ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ'
1612  ],
1613  'trim leading and tailing spaces utf-8' => [
1614  ' test.txt ',
1615  'test.txt'
1616  ],
1617  'remove tailing dot' => [
1618  'test.txt.',
1619  'test.txt'
1620  ],
1621  ];
1622  }
1630  public function ‪sanitizeFileNameUTF8Filesystem(string $fileName, string $expectedResult): void
1631  {
1632  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['UTF8filesystem'] = 1;
1633  self::assertEquals(
1634  $expectedResult,
1635  $this->‪createDriver()->sanitizeFileName($fileName)
1636  );
1637  }
1638 
1649  public function ‪sanitizeFileNameNonUTF8FilesystemDataProvider(): array
1650  {
1651  $this->‪setUpCharacterStrings();
1652  return [
1653  // Characters ordered by ASCII table
1654  'allowed characters iso-8859-1' => [
1655  '-.0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz',
1656  'iso-8859-1',
1657  '-.0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz'
1658  ],
1659  // Characters ordered by ASCII table
1660  'allowed characters utf-8' => [
1661  '-.0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz',
1662  'utf-8',
1663  '-.0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz'
1664  ],
1665  // Characters ordered by ASCII table (except for space-character, because space-character ist trimmed)
1666  'replace special characters with _ (not allowed characters) iso-8859-1' => [
1667  '! "#$%&\'()*+,/:;<=>?[\\]^`{|}~',
1668  'iso-8859-1',
1669  '_____________________________'
1670  ],
1671  // Characters ordered by ASCII table (except for space-character, because space-character ist trimmed)
1672  'replace special characters with _ (not allowed characters) utf-8' => [
1673  '! "#$%&\'()*+,/:;<=>?[\\]^`{|}~',
1674  'utf-8',
1675  '_____________________________'
1676  ],
1677  'iso-8859-1 (code > 127)' => [
1678  // http://de.wikipedia.org/wiki/ISO_8859-1
1679  // chr(0xA0) = NBSP (no-break space) => gets trimmed
1681  'iso-8859-1',
1682  '_centpound_yen____c_a_____R_____-23_u___1o__1_41_23_4_AAAAAEAAAECEEEEIIIIDNOOOOOExOEUUUUEYTHssaaaaaeaaaeceeeeiiiidnoooooe_oeuuuueythy'
1683  ],
1684  'utf-8 (Latin-1 Supplement)' => [
1685  // chr(0xC2) . chr(0x0A) = NBSP (no-break space) => gets trimmed
1687  'utf-8',
1688  '_centpound__yen______c_a_______R_______-23__u_____1o__1_41_23_4_AAAAAEAAAECEEEEIIIIDNOOOOOExOEUUUUEYTHssaaaaaeaaaeceeeeiiiidnoooooe_oeuuuueythy'
1689  ],
1690  'utf-8 (Latin-1 Extended A)' => [
1692  'utf-8',
1693  'AaAaAaCcCcCcCcDdDdEeEeEeEeEeGgGgGgGgHhHhIiIiIiIiIiIJijJjKk__LlLlLlL_l_LlNnNnNn_n____OOooOoOoOEoeRrRrRrSsSsSsSsTtTtTtUuUuUuUuUuUuWwYyYZzZzZzs'
1694  ],
1695  'trim leading and tailing spaces iso-8859-1' => [
1696  ' test.txt ',
1697  'iso-8859-1',
1698  'test.txt'
1699  ],
1700  'trim leading and tailing spaces utf-8' => [
1701  ' test.txt ',
1702  'utf-8',
1703  'test.txt'
1704  ],
1705  'remove tailing dot iso-8859-1' => [
1706  'test.txt.',
1707  'iso-8859-1',
1708  'test.txt'
1709  ],
1710  'remove tailing dot utf-8' => [
1711  'test.txt.',
1712  'utf-8',
1713  'test.txt'
1714  ],
1715  ];
1716  }
1717 
1725  public function ‪sanitizeFileNameNonUTF8Filesystem(string $fileName, string $charset, string $expectedResult): void
1726  {
1727  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['UTF8filesystem'] = 0;
1728  self::assertEquals(
1729  $expectedResult,
1730  $this->‪createDriver()->sanitizeFileName($fileName, $charset)
1731  );
1732  }
1733 
1738  {
1739  $this->expectException(InvalidFileNameException::class);
1740  $this->expectExceptionCode(1320288991);
1741 
1742  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['UTF8filesystem'] = 1;
1743  $this->‪createDriver()->‪sanitizeFileName('');
1744  }
1745 
1750  {
1751  $this->expectException(\Exception::class);
1752  $this->expectExceptionCode(1463073434);
1753  $closure = function () {
1754  throw new \Exception('I was called!', 1463073434);
1755  };
1756 
1757  $filterMethods = [
1758  $closure,
1759  ];
1761  $this->‪createDriver()->_call('applyFilterMethodsToDirectoryItem', $filterMethods, '', '', '');
1762  }
1763 
1768  {
1769  $dummyObject = $this
1770  ->getMockBuilder(LocalDriver::class)
1771  ->setMethods(['dummy'])
1772  ->disableOriginalConstructor()
1773  ->getMock();
1774  $method = [
1775  $dummyObject,
1776  'dummy',
1777  ];
1778  $dummyObject->expects(self::once())->method('dummy');
1779  $filterMethods = [
1780  $method,
1781  ];
1782  $this->‪createDriver()->_call('applyFilterMethodsToDirectoryItem', $filterMethods, '', '', '');
1783  }
1784 }
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\sanitizeFileNameNonUTF8FilesystemDataProvider
‪array sanitizeFileNameNonUTF8FilesystemDataProvider()
Definition: LocalDriverTest.php:1642
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getPublicUrlReturnsValidUrlContainingSpecialCharacters_dataProvider
‪array getPublicUrlReturnsValidUrlContainingSpecialCharacters_dataProvider()
Definition: LocalDriverTest.php:652
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getFilesInFolderReturnsEmptyArrayForEmptyDirectory
‪getFilesInFolderReturnsEmptyArrayForEmptyDirectory()
Definition: LocalDriverTest.php:800
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\sanitizeFileNameNonUTF8Filesystem
‪sanitizeFileNameNonUTF8Filesystem(string $fileName, string $charset, string $expectedResult)
Definition: LocalDriverTest.php:1718
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\$iso88591GreaterThan127
‪string $iso88591GreaterThan127
Definition: LocalDriverTest.php:56
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\$utf8Latin1Supplement
‪string $utf8Latin1Supplement
Definition: LocalDriverTest.php:60
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\sanitizeFileNameUTF8FilesystemDataProvider
‪array sanitizeFileNameUTF8FilesystemDataProvider()
Definition: LocalDriverTest.php:1588
‪TYPO3\CMS\Core\Resource\ResourceStorageInterface
Definition: ResourceStorageInterface.php:22
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getSpecificFileInformationDataProvider
‪array getSpecificFileInformationDataProvider()
Definition: LocalDriverTest.php:428
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getPublicUrlReturnsValidUrlContainingSpecialCharacters
‪getPublicUrlReturnsValidUrlContainingSpecialCharacters(string $fileIdentifier)
Definition: LocalDriverTest.php:667
‪TYPO3\CMS\Core\Core\Environment\getPublicPath
‪static string getPublicPath()
Definition: Environment.php:180
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\$testDirs
‪array $testDirs
Definition: LocalDriverTest.php:52
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\filesCanBeCopiedWithinStorage
‪filesCanBeCopiedWithinStorage()
Definition: LocalDriverTest.php:1182
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\fileContentsCanBeWrittenAndRead
‪fileContentsCanBeWrittenAndRead()
Definition: LocalDriverTest.php:683
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\permissionsAreCorrectlyRetrievedForAllowedFile
‪permissionsAreCorrectlyRetrievedForAllowedFile()
Definition: LocalDriverTest.php:1092
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getFolderInFolderReturnsCorrectFolderObject
‪getFolderInFolderReturnsCorrectFolderObject()
Definition: LocalDriverTest.php:341
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver
Definition: LocalDriver.php:41
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\$backupEnvironment
‪bool $backupEnvironment
Definition: LocalDriverTest.php:44
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getFileInFolderCallsConfiguredCallbackFunctionWithGivenItemName
‪getFileInFolderCallsConfiguredCallbackFunctionWithGivenItemName()
Definition: LocalDriverTest.php:867
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\copyFolderWithinStorageCopiesFileInSingleSubFolderToNewFolderName
‪copyFolderWithinStorageCopiesFileInSingleSubFolderToNewFolderName()
Definition: LocalDriverTest.php:1530
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\copyFolderWithinStorageCopiesSingleFileToNewFolderName
‪copyFolderWithinStorageCopiesSingleFileToNewFolderName()
Definition: LocalDriverTest.php:1501
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\filesCanBeCopiedToATemporaryPath
‪filesCanBeCopiedToATemporaryPath()
Definition: LocalDriverTest.php:1074
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\isFolderEmptyReturnsFalseIfFolderHasFile
‪isFolderEmptyReturnsFalseIfFolderHasFile()
Definition: LocalDriverTest.php:1406
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getPublicUrlReturnsCorrectUriForConfiguredBaseUri
‪getPublicUrlReturnsCorrectUriForConfiguredBaseUri()
Definition: LocalDriverTest.php:631
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getDefaultFolderReturnsFolderForUserUploadPath
‪getDefaultFolderReturnsFolderForUserUploadPath()
Definition: LocalDriverTest.php:322
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\fileMetadataIsChangedAfterMovingFile
‪fileMetadataIsChangedAfterMovingFile()
Definition: LocalDriverTest.php:1224
‪TYPO3\CMS\Core\Core\Environment\isUnix
‪static bool isUnix()
Definition: Environment.php:302
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getFileListReturnsAllFilesInSubdirectoryIfRecursiveParameterIsSet
‪getFileListReturnsAllFilesInSubdirectoryIfRecursiveParameterIsSet()
Definition: LocalDriverTest.php:830
‪TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCase
Definition: BaseTestCase.php:29
‪TYPO3\CMS\Core\Core\Environment\isWindows
‪static bool isWindows()
Definition: Environment.php:292
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\isFolderEmptyReturnsFalseIfFolderHasSubfolder
‪isFolderEmptyReturnsFalseIfFolderHasSubfolder()
Definition: LocalDriverTest.php:1420
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\renamingFolders_dataProvider
‪array renamingFolders_dataProvider()
Definition: LocalDriverTest.php:1300
‪TYPO3\CMS\Core\Core\Environment\getCurrentScript
‪static string getCurrentScript()
Definition: Environment.php:220
‪TYPO3\CMS\Core\Resource\Exception\ExistingTargetFileNameException
Definition: ExistingTargetFileNameException.php:24
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\addFileReturnsFileIdentifier
‪addFileReturnsFileIdentifier()
Definition: LocalDriverTest.php:575
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\renamingFilesFailsIfTargetFileExists
‪renamingFilesFailsIfTargetFileExists()
Definition: LocalDriverTest.php:1284
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\isFolderEmptyReturnsTrueForEmptyFolder
‪isFolderEmptyReturnsTrueForEmptyFolder()
Definition: LocalDriverTest.php:1392
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\setUpCharacterStrings
‪setUpCharacterStrings()
Definition: LocalDriverTest.php:1549
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\isWithinAcceptsFileAndFolderObjectsAsContent
‪isWithinAcceptsFileAndFolderObjectsAsContent()
Definition: LocalDriverTest.php:1168
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\determineBaseUrlUrlEncodesUriParts
‪determineBaseUrlUrlEncodesUriParts()
Definition: LocalDriverTest.php:297
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\createFolderSanitizesFolderNameBeforeCreation
‪createFolderSanitizesFolderNameBeforeCreation(string $newFolderName, string $expectedFolderName)
Definition: LocalDriverTest.php:399
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\newFilesCanBeCreated
‪newFilesCanBeCreated()
Definition: LocalDriverTest.php:719
‪$dir
‪$dir
Definition: validateRstFiles.php:213
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\createRealTestdir
‪string createRealTestdir()
Definition: LocalDriverTest.php:86
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\createFolderCreatesFolderOnDisk
‪createFolderCreatesFolderOnDisk()
Definition: LocalDriverTest.php:356
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\addFileFailsIfFileIsInDriverStorage
‪addFileFailsIfFileIsInDriverStorage()
Definition: LocalDriverTest.php:559
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\$resetSingletonInstances
‪bool $resetSingletonInstances
Definition: LocalDriverTest.php:40
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getFolderListFailsIfDirectoryDoesNotExist
‪getFolderListFailsIfDirectoryDoesNotExist()
Definition: LocalDriverTest.php:1004
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\foldersCanBeMovedWithinStorage
‪foldersCanBeMovedWithinStorage()
Definition: LocalDriverTest.php:1437
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\applyFilterMethodsToDirectoryItemCallsFilterMethodIfClosure
‪applyFilterMethodsToDirectoryItemCallsFilterMethodIfClosure()
Definition: LocalDriverTest.php:1742
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\hashReturnsCorrectHashes
‪hashReturnsCorrectHashes()
Definition: LocalDriverTest.php:1016
‪TYPO3\CMS\Core\Core\Environment\getContext
‪static ApplicationContext getContext()
Definition: Environment.php:133
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver
Definition: AbstractDriverTest.php:16
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\applyFilterMethodsToDirectoryItemCallsFilterMethodIfName
‪applyFilterMethodsToDirectoryItemCallsFilterMethodIfName()
Definition: LocalDriverTest.php:1760
‪TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCase\addToVfs
‪addToVfs(array $dirStructure)
Definition: BaseTestCase.php:89
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\calculatedBasePathAbsoluteIsSane
‪calculatedBasePathAbsoluteIsSane()
Definition: LocalDriverTest.php:164
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getFileForLocalProcessingCreatesCopyOfFileByDefault
‪getFileForLocalProcessingCreatesCopyOfFileByDefault()
Definition: LocalDriverTest.php:1042
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\hashingWithUnsupportedAlgorithmFails
‪hashingWithUnsupportedAlgorithmFails()
Definition: LocalDriverTest.php:1030
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\createdFilesAreEmpty
‪createdFilesAreEmpty()
Definition: LocalDriverTest.php:730
‪TYPO3\CMS\Core\Core\Environment\getProjectPath
‪static string getProjectPath()
Definition: Environment.php:169
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\renameFolderReturnsCorrectMappingInformationForAllFiles
‪renameFolderReturnsCorrectMappingInformationForAllFiles()
Definition: LocalDriverTest.php:1349
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getAbsolutePathReturnsCorrectPath
‪getAbsolutePathReturnsCorrectPath()
Definition: LocalDriverTest.php:503
‪TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCase\$basedir
‪string $basedir
Definition: BaseTestCase.php:32
‪TYPO3\CMS\Core\Utility\GeneralUtility\fixPermissions
‪static mixed fixPermissions($path, $recursive=false)
Definition: GeneralUtility.php:1863
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\createFileFixesPermissionsOnCreatedFile
‪createFileFixesPermissionsOnCreatedFile()
Definition: LocalDriverTest.php:742
‪TYPO3\CMS\Core\Utility\GeneralUtility\mkdir_deep
‪static mkdir_deep($directory)
Definition: GeneralUtility.php:2022
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getFileThrowsExceptionIfFileDoesNotExist
‪getFileThrowsExceptionIfFileDoesNotExist()
Definition: LocalDriverTest.php:789
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\callbackStaticTestFunction
‪static callbackStaticTestFunction(string $itemName)
Definition: LocalDriverTest.php:896
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\folderCanBeRenamedWhenMoving
‪folderCanBeRenamedWhenMoving()
Definition: LocalDriverTest.php:1485
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\defaultLevelFolderFolderIsCreatedIfItDoesntExist
‪defaultLevelFolderFolderIsCreatedIfItDoesntExist()
Definition: LocalDriverTest.php:332
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\existenceChecksInFolderWorkForFilesAndFolders
‪existenceChecksInFolderWorkForFilesAndFolders()
Definition: LocalDriverTest.php:613
‪TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCase\getMountRootUrl
‪getMountRootUrl()
Definition: BaseTestCase.php:48
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\sanitizeFileNameThrowsExceptionOnInvalidFileName
‪sanitizeFileNameThrowsExceptionOnInvalidFileName()
Definition: LocalDriverTest.php:1730
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\$localDriver
‪LocalDriver $localDriver
Definition: LocalDriverTest.php:48
‪TYPO3\CMS\Core\Core\Environment\initialize
‪static initialize(ApplicationContext $context, bool $cli, bool $composerMode, string $projectPath, string $publicPath, string $varPath, string $configPath, string $currentScript, string $os)
Definition: Environment.php:104
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\existenceChecksWorkForFilesAndFolders
‪existenceChecksWorkForFilesAndFolders()
Definition: LocalDriverTest.php:596
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\permissionsAreCorrectlyRetrievedForAllowedFolder
‪permissionsAreCorrectlyRetrievedForAllowedFolder()
Definition: LocalDriverTest.php:1123
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\permissionsAreCorrectlyRetrievedForForbiddenFile
‪permissionsAreCorrectlyRetrievedForForbiddenFile()
Definition: LocalDriverTest.php:1105
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\setFileContentsReturnsNumberOfBytesWrittenToFile
‪setFileContentsReturnsNumberOfBytesWrittenToFile()
Definition: LocalDriverTest.php:703
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getFileForLocalProcessingReturnsOriginalFilepathForReadonlyAccess
‪getFileForLocalProcessingReturnsOriginalFilepathForReadonlyAccess()
Definition: LocalDriverTest.php:1058
‪TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCase\getUrlInMount
‪string getUrlInMount($path)
Definition: BaseTestCase.php:79
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\$utf8Latin1ExtendedA
‪string $utf8Latin1ExtendedA
Definition: LocalDriverTest.php:64
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\prepareRealTestEnvironment
‪array prepareRealTestEnvironment()
Definition: LocalDriverTest.php:100
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\addFileUsesFilenameIfGiven
‪addFileUsesFilenameIfGiven()
Definition: LocalDriverTest.php:539
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\createFolderSanitizesFolderNameBeforeCreationDataProvider
‪static array createFolderSanitizesFolderNameBeforeCreationDataProvider()
Definition: LocalDriverTest.php:379
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\copyFolderWithinStorageCopiesSingleSubFolderToNewFolderName
‪copyFolderWithinStorageCopiesSingleSubFolderToNewFolderName()
Definition: LocalDriverTest.php:1517
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getFolderListReturnsAllDirectoriesInDirectory
‪getFolderListReturnsAllDirectoriesInDirectory()
Definition: LocalDriverTest.php:931
‪TYPO3\CMS\Core\Utility\GeneralUtility\isValidUrl
‪static bool isValidUrl($url)
Definition: GeneralUtility.php:944
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\isWithinRecognizesFilesWithinFolderAndInOtherFolders
‪isWithinRecognizesFilesWithinFolderAndInOtherFolders()
Definition: LocalDriverTest.php:1157
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\permissionsAreCorrectlyRetrievedForForbiddenFolder
‪permissionsAreCorrectlyRetrievedForForbiddenFolder()
Definition: LocalDriverTest.php:1136
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\addFileMovesFileToCorrectLocation
‪addFileMovesFileToCorrectLocation()
Definition: LocalDriverTest.php:519
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\calculatedBasePathRelativeIsSane
‪calculatedBasePathRelativeIsSane()
Definition: LocalDriverTest.php:147
‪TYPO3\CMS\Core\Resource\ResourceStorage
Definition: ResourceStorage.php:122
‪TYPO3\CMS\Core\Utility\StringUtility\getUniqueId
‪static string getUniqueId($prefix='')
Definition: StringUtility.php:92
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\renamingFoldersChangesFolderNameOnDisk
‪renamingFoldersChangesFolderNameOnDisk(array $filesystemStructure, string $oldFolderIdentifier, string $newFolderName, string $expectedNewIdentifier)
Definition: LocalDriverTest.php:1332
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getFileListReturnsAllFilesInDirectory
‪getFileListReturnsAllFilesInDirectory()
Definition: LocalDriverTest.php:810
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getFolderListFiltersItemsWithGivenFilterMethods
‪getFolderListFiltersItemsWithGivenFilterMethods()
Definition: LocalDriverTest.php:983
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\noSecondSlashIsAddedIfBasePathAlreadyHasTrailingSlash
‪noSecondSlashIsAddedIfBasePathAlreadyHasTrailingSlash()
Definition: LocalDriverTest.php:419
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\basePathIsNormalizedWithTrailingSlash
‪basePathIsNormalizedWithTrailingSlash()
Definition: LocalDriverTest.php:410
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\createDriver
‪LocalDriver createDriver(array $driverConfiguration=[], array $mockedDriverMethods=[])
Definition: LocalDriverTest.php:118
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getFileReturnsCorrectIdentifier
‪getFileReturnsCorrectIdentifier()
Definition: LocalDriverTest.php:770
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getFileListFailsIfDirectoryDoesNotExist
‪getFileListFailsIfDirectoryDoesNotExist()
Definition: LocalDriverTest.php:855
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:40
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest
Definition: LocalDriverTest.php:37
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\filesCanBeMovedWithinStorage
‪filesCanBeMovedWithinStorage()
Definition: LocalDriverTest.php:1200
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\tearDown
‪tearDown()
Definition: LocalDriverTest.php:69
‪TYPO3\CMS\Core\Utility\GeneralUtility\rmdir
‪static bool rmdir($path, $removeNonEmpty=false)
Definition: GeneralUtility.php:2075
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\renamingFiles_dataProvider
‪renamingFiles_dataProvider()
Definition: LocalDriverTest.php:1241
‪TYPO3\CMS\Core\Core\Environment\getConfigPath
‪static string getConfigPath()
Definition: Environment.php:210
‪TYPO3\CMS\Core\Resource\ResourceStorageInterface\CAPABILITY_PUBLIC
‪const CAPABILITY_PUBLIC
Definition: ResourceStorageInterface.php:170
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\createFolderRecursiveSanitizesFilename
‪createFolderRecursiveSanitizesFilename()
Definition: LocalDriverTest.php:281
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\sanitizeFileNameUTF8Filesystem
‪sanitizeFileNameUTF8Filesystem(string $fileName, string $expectedResult)
Definition: LocalDriverTest.php:1623
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\moveFolderWithinStorageReturnsCorrectMappingInformationForAllFiles
‪moveFolderWithinStorageReturnsCorrectMappingInformationForAllFiles()
Definition: LocalDriverTest.php:1462
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\Fixtures\LocalDriverFilenameFilter
Definition: LocalDriverFilenameFilter.php:24
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCase\getUrl
‪string getUrl($path)
Definition: BaseTestCase.php:100
‪TYPO3\CMS\Core\Resource\Exception\FileOperationErrorException
Definition: FileOperationErrorException.php:22
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getFileListFiltersItemsWithGivenFilterMethods
‪getFileListFiltersItemsWithGivenFilterMethods()
Definition: LocalDriverTest.php:906
‪TYPO3\CMS\Core\Utility\StringUtility
Definition: StringUtility.php:22
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getFolderListLeavesOutNavigationalEntries
‪getFolderListLeavesOutNavigationalEntries()
Definition: LocalDriverTest.php:967
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\publicUrlIsCalculatedCorrectlyWithDifferentBasePathsAndBasUrisDataProvider
‪publicUrlIsCalculatedCorrectlyWithDifferentBasePathsAndBasUrisDataProvider()
Definition: LocalDriverTest.php:181
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\sanitizeFileName
‪string sanitizeFileName($fileName, $charset='utf-8')
Definition: LocalDriver.php:313
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\renamingFilesChangesFilenameOnDisk
‪renamingFilesChangesFilenameOnDisk(array $filesystemStructure, string $oldFileIdentifier, string $newFileName, string $expectedNewIdentifier)
Definition: LocalDriverTest.php:1271
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\createFolderReturnsFolderObject
‪createFolderReturnsFolderObject()
Definition: LocalDriverTest.php:368
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getFolderListReturnsHiddenFoldersByDefault
‪getFolderListReturnsHiddenFoldersByDefault()
Definition: LocalDriverTest.php:947
‪TYPO3\CMS\Core\Resource\Exception\InvalidFileNameException
Definition: InvalidFileNameException.php:24
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\publicUrlIsCalculatedCorrectlyWithDifferentBasePathsAndBasUris
‪publicUrlIsCalculatedCorrectlyWithDifferentBasePathsAndBasUris(string $basePath, string $baseUri, string $fileName, bool $expectedIsPublic, ?string $expectedPublicUrl)
Definition: LocalDriverTest.php:245
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getSpecificFileInformationReturnsRequestedFileInformation
‪getSpecificFileInformationReturnsRequestedFileInformation($expectedValue, string $property)
Definition: LocalDriverTest.php:480
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\renameFolderRevertsRenamingIfFilenameMapCannotBeCreated
‪renameFolderRevertsRenamingIfFilenameMapCannotBeCreated()
Definition: LocalDriverTest.php:1370
‪TYPO3\CMS\Core\Core\Environment\getVarPath
‪static string getVarPath()
Definition: Environment.php:192
‪TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCase\addToMount
‪addToMount(array $dirStructure)
Definition: BaseTestCase.php:68
‪TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCase\initializeVfs
‪initializeVfs()
Definition: BaseTestCase.php:58