‪TYPO3CMS  11.5
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;
21 use PHPUnit\Framework\MockObject\MockObject;
33 use TYPO3\TestingFramework\Core\AccessibleObjectInterface;
34 
36 {
40  protected ‪$resetSingletonInstances = true;
41 
45  protected ‪$backupEnvironment = true;
46 
48  protected array ‪$testDirs = [];
49  protected string ‪$iso88591GreaterThan127 = '';
50  protected string ‪$utf8Latin1Supplement = '';
51  protected string ‪$utf8Latin1ExtendedA = '';
52 
56  protected function ‪tearDown(): void
57  {
58  foreach ($this->testDirs as ‪$dir) {
59  chmod(‪$dir, 0777);
61  }
62  parent::tearDown();
63  }
64 
73  protected function ‪createRealTestdir(): string
74  {
76  mkdir(‪$basedir);
77  $this->testDirs[] = ‪$basedir;
78  return ‪$basedir;
79  }
80 
87  protected function ‪prepareRealTestEnvironment(): array
88  {
90  $subject = $this->‪createDriver([
91  'basePath' => ‪$basedir,
92  ]);
93  return [‪$basedir, $subject];
94  }
95 
103  protected function ‪createDriver(array $driverConfiguration = [], array $mockedDriverMethods = [])
104  {
105  // it's important to do that here, so vfsContents could have been set before
106  if (!isset($driverConfiguration['basePath'])) {
107  $this->‪initializeVfs();
108  $driverConfiguration['basePath'] = $this->‪getMountRootUrl();
109  }
110  $mockedDriverMethods[] = 'isPathValid';
111  $driver = $this->getAccessibleMock(
112  LocalDriver::class,
113  $mockedDriverMethods,
114  [$driverConfiguration]
115  );
116  $driver
117  ->method('isPathValid')
118  ->willReturn(
119  true
120  );
121 
122  $driver->setStorageUid(5);
123  $driver->processConfiguration();
124  $driver->initialize();
125  return $driver;
126  }
127 
131  public function ‪calculatedBasePathRelativeIsSane(): void
132  {
133  $subject = $this->‪createDriver();
134 
135  // 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
136  $relativeDriverConfiguration = [
137  'pathType' => 'relative',
138  'basePath' => '/typo3temp/var/tests/',
139  ];
140  $basePath = $subject->_call('calculateBasePath', $relativeDriverConfiguration);
141 
142  self::assertStringNotContainsString('//', $basePath);
143  }
144 
148  public function ‪calculatedBasePathAbsoluteIsSane(): void
149  {
150  $subject = $this->‪createDriver();
151 
152  // This test checks if "/../" are properly filtered out (i.e. from "Base path" field of sys_file_storage)
153  $varPath = ‪Environment::getVarPath();
154  $projectPath = ‪Environment::getProjectPath();
155  $relativeVarPath = str_replace($projectPath, '', $varPath);
156  $segments = str_repeat('/..', substr_count($relativeVarPath, '/') + 1);
157  $relativeDriverConfiguration = [
158  'basePath' => ‪Environment::getVarPath() . '/tests' . $segments . $relativeVarPath . '/tests/',
159  ];
160  $basePath = $subject->_call('calculateBasePath', $relativeDriverConfiguration);
161 
162  self::assertStringNotContainsString('/../', $basePath);
163  }
164 
166  {
167  return [
168  'no base uri, within public' => [
169  '/files/',
170  '',
171  '/foo.txt',
172  true,
173  'files/foo.txt',
174  ],
175  'no base uri, within project' => [
176  '/../files/',
177  '',
178  '/foo.txt',
179  false,
180  null,
181  ],
182  'base uri with host, within public' => [
183  '/files/',
184  'https://host.tld/',
185  '/foo.txt',
186  true,
187  'https://host.tld/foo.txt',
188  ],
189  'base uri with host, within project' => [
190  '/../files/',
191  'https://host.tld/',
192  '/foo.txt',
193  true,
194  'https://host.tld/foo.txt',
195  ],
196  'base uri with path only, within public' => [
197  '/files/',
198  'assets/',
199  '/foo.txt',
200  true,
201  'assets/foo.txt',
202  ],
203  'base uri with path only, within project' => [
204  '/../files/',
205  'assets/',
206  '/foo.txt',
207  true,
208  'assets/foo.txt',
209  ],
210  'base uri with path only, within other public dir' => [
211  '/../public/assets/',
212  'assets/',
213  '/foo.txt',
214  true,
215  'assets/foo.txt',
216  ],
217  ];
218  }
219 
230  string $basePath,
231  string $baseUri,
232  string $fileName,
233  bool $expectedIsPublic,
234  ?string $expectedPublicUrl
235  ): void {
236  $testDir = $this->‪createRealTestdir();
237  $projectPath = $testDir . '/app';
238  $publicPath = $projectPath . '/public';
239  $absoluteBaseDir = $publicPath . $basePath;
240  mkdir($projectPath);
241  mkdir($publicPath);
242  mkdir($absoluteBaseDir, 0777, true);
245  true,
246  false,
247  $projectPath,
248  $publicPath,
252  ‪Environment::isUnix() ? 'UNIX' : 'WINDOWS'
253  );
254  $driverConfiguration = [
255  'pathType' => 'relative',
256  'basePath' => $basePath,
257  'baseUri' => $baseUri,
258  ];
259 
260  $subject = $this->‪createDriver($driverConfiguration);
261 
262  self::assertSame($expectedIsPublic, $subject->hasCapability(‪ResourceStorageInterface::CAPABILITY_PUBLIC));
263  self::assertSame($fileName, $subject->createFile($fileName, '/'));
264  self::assertSame($expectedPublicUrl, $subject->getPublicUrl($fileName));
265  }
266 
270  public function ‪createFolderRecursiveSanitizesFilename(): void
271  {
272  $driver = $this->‪createDriver([], ['sanitizeFilename']);
273  $driver->expects(self::exactly(2))
274  ->method('sanitizeFileName')
275  ->willReturn(
276  'sanitized'
277  );
278  $driver->createFolder('newFolder/andSubfolder', '/', true);
279  self::assertFileExists($this->‪getUrlInMount('/sanitized/sanitized/'));
280  }
281 
285  public function ‪determineBaseUrlUrlEncodesUriParts(): void
286  {
287  $driver = $this->getAccessibleMock(
288  LocalDriver::class,
289  ['hasCapability'],
290  [],
291  '',
292  false
293  );
294  $driver->expects(self::once())
295  ->method('hasCapability')
297  ->willReturn(
298  true
299  );
300  $driver->_set('absoluteBasePath', ‪Environment::getPublicPath() . '/un encö/ded %path/');
301  $driver->_call('determineBaseUrl');
302  $baseUri = $driver->_get('baseUri');
303  self::assertEquals(rawurlencode('un encö') . '/' . rawurlencode('ded %path') . '/', $baseUri);
304  }
305 
310  {
311  $subject = $this->‪createDriver();
312  $folderIdentifier = $subject->getDefaultFolder();
313  self::assertEquals('/user_upload/', $folderIdentifier);
314  }
315 
320  {
321  $subject = $this->‪createDriver();
322  self::assertFileExists($this->‪getUrlInMount($subject->getDefaultFolder()));
323  }
324 
328  public function ‪getFolderInFolderReturnsCorrectFolderObject(): void
329  {
330  $this->‪addToMount([
331  'someDir' => [
332  'someSubdir' => [],
333  ],
334  ]);
335  $subject = $this->‪createDriver();
336  $folder = $subject->getFolderInFolder('someSubdir', '/someDir/');
337  self::assertEquals('/someDir/someSubdir/', $folder);
338  }
339 
343  public function ‪createFolderCreatesFolderOnDisk(): void
344  {
345  $this->‪addToMount(['some' => ['folder' => []]]);
346  $subject = $this->‪createDriver();
347  $subject->createFolder('path', '/some/folder/');
348  self::assertFileExists($this->‪getUrlInMount('/some/folder/'));
349  self::assertFileExists($this->‪getUrlInMount('/some/folder/path'));
350  }
351 
355  public function ‪createFolderReturnsFolderObject(): void
356  {
357  $this->‪addToMount(['some' => ['folder' => []]]);
358  $subject = $this->‪createDriver();
359  $createdFolder = $subject->createFolder('path', '/some/folder/');
360  self::assertEquals('/some/folder/path/', $createdFolder);
361  }
362 
367  {
368  return [
369  'folder name with NULL character' => [
370  'some' . "\0" . 'Folder',
371  'some_Folder',
372  ],
373  'folder name with directory part' => [
374  '../someFolder',
375  '.._someFolder',
376  ],
377  ];
378  }
379 
386  public function ‪createFolderSanitizesFolderNameBeforeCreation(string $newFolderName, string $expectedFolderName): void
387  {
388  $this->‪addToMount(['some' => ['folder' => []]]);
389  $subject = $this->‪createDriver();
390  $subject->createFolder($newFolderName, '/some/folder/');
391  self::assertFileExists($this->‪getUrlInMount('/some/folder/' . $expectedFolderName));
392  }
393 
397  public function ‪basePathIsNormalizedWithTrailingSlash(): void
398  {
399  $subject = $this->‪createDriver();
400  self::assertEquals('/', substr($subject->_call('getAbsoluteBasePath'), -1));
401  }
402 
407  {
408  $subject = $this->‪createDriver();
409  self::assertNotEquals('/', substr($subject->_call('getAbsoluteBasePath'), -2, 1));
410  }
411 
415  public function ‪getSpecificFileInformationDataProvider(): array
416  {
417  return [
418  'size' => [
419  'expectedValue' => filesize(__DIR__ . '/Fixtures/Dummy.html'),
420  'propertyName' => 'size',
421  ],
422  'atime' => [
423  'expectedValue' => 'WILL_BE_REPLACED_BY_VFS_TIME',
424  'propertyName' => 'atime',
425  ],
426  'mtime' => [
427  'expectedValue' => 'WILL_BE_REPLACED_BY_VFS_TIME',
428  'propertyName' => 'mtime',
429  ],
430  'ctime' => [
431  'expectedValue' => 'WILL_BE_REPLACED_BY_VFS_TIME',
432  'propertyName' => 'ctime',
433  ],
434  'name' => [
435  'expectedValue' => 'Dummy.html',
436  'propertyName' => 'name',
437  ],
438  'mimetype' => [
439  'expectedValue' => 'text/html',
440  'propertyName' => 'mimetype',
441  ],
442  'identifier' => [
443  'expectedValue' => '/Dummy.html',
444  'propertyName' => 'identifier',
445  ],
446  'storage' => [
447  'expectedValue' => 5,
448  'propertyName' => 'storage',
449  ],
450  'identifier_hash' => [
451  'expectedValue' => 'b11efa5d7c0556a65c6aa261343b9807cac993bc',
452  'propertyName' => 'identifier_hash',
453  ],
454  'folder_hash' => [
455  'expectedValue' => '42099b4af021e53fd8fd4e056c2568d7c2e3ffa8',
456  'propertyName' => 'folder_hash',
457  ],
458  ];
459  }
460 
467  public function ‪getSpecificFileInformationReturnsRequestedFileInformation($expectedValue, string $property): void
468  {
469  $root = vfsStream::setup('root');
470 
471  $subFolder = vfsStream::newDirectory('fileadmin');
472  $root->addChild($subFolder);
473 
474  // Load fixture files and folders from disk
475  $directory = vfsStream::copyFromFileSystem(__DIR__ . '/Fixtures/', $subFolder, 1024 * 1024);
476  if (in_array($property, ['mtime', 'ctime', 'atime'])) {
477  $expectedValue = $directory->getChild('Dummy.html')->filemtime();
478  }
479 
480  $subject = $this->‪createDriver(['basePath' => 'vfs://root/fileadmin']);
481  self::assertSame(
482  $expectedValue,
483  $subject->getSpecificFileInformation('vfs://root/fileadmin/Dummy.html', '/', $property)
484  );
485  }
486 
490  public function ‪getAbsolutePathReturnsCorrectPath(): void
491  {
492  $this->‪addToMount([
493  'someFolder' => [
494  'file1.ext' => 'asdfg',
495  ],
496  ]);
497  $subject = $this->‪createDriver();
498  $path = $subject->_call('getAbsolutePath', '/someFolder/file1.ext');
499  self::assertFileExists($path);
500  self::assertEquals($this->‪getUrlInMount('/someFolder/file1.ext'), $path);
501  }
502 
506  public function ‪addFileMovesFileToCorrectLocation(): void
507  {
508  $this->‪addToMount(['targetFolder' => []]);
509  $this->‪addToVfs([
510  'sourceFolder' => [
511  'file' => 'asdf',
512  ],
513  ]);
514  $subject = $this->‪createDriver(
515  [],
516  ['getMimeTypeOfFile']
517  );
518  self::assertFileExists($this->‪getUrl('sourceFolder/file'));
519  $subject->addFile($this->‪getUrl('sourceFolder/file'), '/targetFolder/', 'file');
520  self::assertFileExists($this->‪getUrlInMount('/targetFolder/file'));
521  }
522 
526  public function ‪addFileUsesFilenameIfGiven(): 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::assertFileExists($this->‪getUrl('sourceFolder/file'));
539  $subject->addFile($this->‪getUrl('sourceFolder/file'), '/targetFolder/', 'targetFile');
540  self::assertFileExists($this->‪getUrlInMount('/targetFolder/targetFile'));
541  }
542 
546  public function ‪addFileFailsIfFileIsInDriverStorage(): void
547  {
548  $this->expectException(\InvalidArgumentException::class);
549  $this->expectExceptionCode(1314778269);
550  $this->‪addToMount([
551  'targetFolder' => [
552  'file' => 'asdf',
553  ],
554  ]);
555  $subject = $this->‪createDriver();
556  $subject->addFile($this->‪getUrlInMount('/targetFolder/file'), '/targetFolder/', 'file');
557  }
558 
562  public function ‪addFileReturnsFileIdentifier(): void
563  {
564  $this->‪addToMount(['targetFolder' => []]);
565  $this->‪addToVfs([
566  'sourceFolder' => [
567  'file' => 'asdf',
568  ],
569  ]);
570  $subject = $this->‪createDriver(
571  [],
572  ['getMimeTypeOfFile']
573  );
574  self::assertFileExists($this->‪getUrl('sourceFolder/file'));
575  $fileIdentifier = $subject->addFile($this->‪getUrl('sourceFolder/file'), '/targetFolder/', 'file');
576  self::assertEquals('file', basename($fileIdentifier));
577  self::assertEquals('/targetFolder/file', $fileIdentifier);
578  }
579 
583  public function ‪existenceChecksWorkForFilesAndFolders(): void
584  {
585  $this->‪addToMount([
586  'file' => 'asdf',
587  'folder' => [],
588  ]);
589  $subject = $this->‪createDriver();
590  // Using slashes at the beginning of paths because they will be stored in the DB this way.
591  self::assertTrue($subject->fileExists('/file'));
592  self::assertTrue($subject->folderExists('/folder/'));
593  self::assertFalse($subject->fileExists('/nonexistingFile'));
594  self::assertFalse($subject->folderExists('/nonexistingFolder/'));
595  }
596 
601  {
602  $this->‪addToMount([
603  'subfolder' => [
604  'file' => 'asdf',
605  'folder' => [],
606  ],
607  ]);
608  $subject = $this->‪createDriver();
609  self::assertTrue($subject->fileExistsInFolder('file', '/subfolder/'));
610  self::assertTrue($subject->folderExistsInFolder('folder', '/subfolder/'));
611  self::assertFalse($subject->fileExistsInFolder('nonexistingFile', '/subfolder/'));
612  self::assertFalse($subject->folderExistsInFolder('nonexistingFolder', '/subfolder/'));
613  }
614 
619  {
620  $baseUri = 'http://example.org/foobar/' . ‪StringUtility::getUniqueId('uri_');
621  $this->‪addToMount([
622  'file.ext' => 'asdf',
623  'subfolder' => [
624  'file2.ext' => 'asdf',
625  ],
626  ]);
627  $subject = $this->‪createDriver([
628  'baseUri' => $baseUri,
629  ]);
630  self::assertEquals($baseUri . '/file.ext', $subject->getPublicUrl('/file.ext'));
631  self::assertEquals($baseUri . '/subfolder/file2.ext', $subject->getPublicUrl('/subfolder/file2.ext'));
632  }
633 
640  {
641  return [
642  ['/single file with some special chars äüö!.txt'],
643  ['/on subfolder/with special chars äüö!.ext'],
644  ['/who names a file like !"§$%&()=?*+~"#\'´`<>-.ext'],
645  ['no leading slash !"§$%&()=?*+~#\'"´`"<>-.txt'],
646  ];
647  }
648 
654  public function ‪getPublicUrlReturnsValidUrlContainingSpecialCharacters(string $fileIdentifier): void
655  {
656  $baseUri = 'http://example.org/foobar/' . ‪StringUtility::getUniqueId('uri_');
657  $subject = $this->‪createDriver([
658  'baseUri' => $baseUri,
659  ]);
660  $publicUrl = $subject->getPublicUrl($fileIdentifier);
661  self::assertTrue(
662  ‪GeneralUtility::isValidUrl($publicUrl),
663  'getPublicUrl did not return a valid URL:' . $publicUrl
664  );
665  }
666 
670  public function ‪fileContentsCanBeWrittenAndRead(): void
671  {
672  $fileContents = 'asdf';
673  $this->‪addToMount([
674  'file.ext' => $fileContents,
675  ]);
676  $subject = $this->‪createDriver();
677  self::assertEquals($fileContents, $subject->getFileContents('/file.ext'), 'File contents could not be read');
678  $newFileContents = 'asdfgh';
679  $subject->setFileContents('/file.ext', $newFileContents);
680  self::assertEquals(
681  $newFileContents,
682  $subject->getFileContents('/file.ext'),
683  'New file contents could not be read.'
684  );
685  }
686 
691  {
692  $fileContents = 'asdf';
693  $this->‪addToMount([
694  'file.ext' => $fileContents,
695  ]);
696  $subject = $this->‪createDriver();
697  $newFileContents = 'asdfgh';
698  $bytesWritten = $subject->setFileContents('/file.ext', $newFileContents);
699  self::assertEquals(strlen($newFileContents), $bytesWritten);
700  }
701 
706  public function ‪newFilesCanBeCreated(): void
707  {
708  $subject = $this->‪createDriver();
709  $subject->createFile('testfile.txt', '/');
710  self::assertTrue($subject->fileExists('/testfile.txt'));
711  }
712 
717  public function ‪createdFilesAreEmpty(): void
718  {
719  $subject = $this->‪createDriver();
720  $subject->createFile('testfile.txt', '/');
721  self::assertTrue($subject->fileExists('/testfile.txt'));
722  $fileData = $subject->getFileContents('/testfile.txt');
723  self::assertEquals(0, strlen($fileData));
724  }
725 
729  public function ‪createFileFixesPermissionsOnCreatedFile(): void
730  {
732  self::markTestSkipped('createdFilesHaveCorrectRights() tests not available on Windows');
733  }
734 
735  // No one will use this as his default file create mask so we hopefully don't get any false positives
736  $testpattern = '0646';
737  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask'] = $testpattern;
738 
739  $this->‪addToMount(
740  [
741  'someDir' => [],
742  ]
743  );
745  [‪$basedir, $subject] = $this->‪prepareRealTestEnvironment();
746  mkdir(‪$basedir . '/someDir');
747  $subject->createFile('testfile.txt', '/someDir');
748  self::assertEquals((int)$testpattern, (int)(decoct(fileperms(‪$basedir . '/someDir/testfile.txt') & 0777)));
749  }
750 
751  /**********************************
752  * File and directory listing
753  **********************************/
757  public function ‪getFileReturnsCorrectIdentifier(): void
758  {
759  $root = vfsStream::setup('root');
760  $subFolder = vfsStream::newDirectory('fileadmin');
761  $root->addChild($subFolder);
762  // Load fixture files and folders from disk
763  vfsStream::copyFromFileSystem(__DIR__ . '/Fixtures/', $subFolder, 1024 * 1024);
764 
765  $subject = $this->‪createDriver(['basePath' => 'vfs://root/fileadmin']);
766 
767  $subdirFileInfo = $subject->getFileInfoByIdentifier('Dummy.html');
768  self::assertEquals('/Dummy.html', $subdirFileInfo['identifier']);
769  $rootFileInfo = $subject->getFileInfoByIdentifier('LocalDriverFilenameFilter.php');
770  self::assertEquals('/LocalDriverFilenameFilter.php', $rootFileInfo['identifier']);
771  }
772 
776  public function ‪getFileThrowsExceptionIfFileDoesNotExist(): void
777  {
778  $this->expectException(\InvalidArgumentException::class);
779  $this->expectExceptionCode(1314516809);
780  $subject = $this->‪createDriver();
781  $subject->getFileInfoByIdentifier('/some/file/at/a/random/path');
782  }
783 
788  {
789  $subject = $this->‪createDriver();
790  $fileList = $subject->getFilesInFolder('/');
791  self::assertEmpty($fileList);
792  }
793 
797  public function ‪getFileListReturnsAllFilesInDirectory(): void
798  {
799  $dirStructure = [
800  'aDir' => [],
801  'file1' => 'asdfg',
802  'file2' => 'fdsa',
803  ];
804  $this->‪addToMount($dirStructure);
805  $subject = $this->‪createDriver(
806  [],
807  // Mocked because finfo() can not deal with vfs streams and throws warnings
808  ['getMimeTypeOfFile']
809  );
810  $fileList = $subject->getFilesInFolder('/');
811  self::assertEquals(['/file1', '/file2'], array_keys($fileList));
812  }
813 
818  {
819  $dirStructure = [
820  'aDir' => [
821  'file3' => 'asdfgh',
822  'subdir' => [
823  'file4' => 'asklfjklasjkl',
824  ],
825  ],
826  'file1' => 'asdfg',
827  'file2' => 'fdsa',
828  ];
829  $this->‪addToMount($dirStructure);
830  $subject = $this->‪createDriver(
831  [],
832  // Mocked because finfo() can not deal with vfs streams and throws warnings
833  ['getMimeTypeOfFile']
834  );
835  $fileList = $subject->getFilesInFolder('/', 0, 0, true);
836  self::assertEquals(['/file1', '/file2', '/aDir/file3', '/aDir/subdir/file4'], array_keys($fileList));
837  }
838 
842  public function ‪getFileListFailsIfDirectoryDoesNotExist(): void
843  {
844  $this->expectException(\InvalidArgumentException::class);
845  $this->expectExceptionCode(1314349666);
846  $this->‪addToMount(['somefile' => '']);
847  $subject = $this->‪createDriver();
848  $subject->getFilesInFolder('somedir/');
849  }
850 
855  {
856  $dirStructure = [
857  'file2' => 'fdsa',
858  ];
859  // register static callback to self
860  $callback = [
861  [
862  static::class,
863  'callbackStaticTestFunction',
864  ],
865  ];
866  $this->‪addToMount($dirStructure);
867  $subject = $this->‪createDriver();
868  // the callback function will throw an exception used to check if it was called with correct $itemName
869  $this->expectException(\InvalidArgumentException::class);
870  $this->expectExceptionCode(1336159604);
871  $subject->getFilesInFolder('/', 0, 0, false, $callback);
872  }
873 
883  public static function ‪callbackStaticTestFunction(string $itemName): void
884  {
885  if ($itemName === 'file2') {
886  throw new \InvalidArgumentException('$itemName', 1336159604);
887  }
888  }
889 
894  {
895  $dirStructure = [
896  'fileA' => 'asdfg',
897  'fileB' => 'fdsa',
898  ];
899  $this->‪addToMount($dirStructure);
900  $subject = $this->‪createDriver(
901  [],
902  // Mocked because finfo() can not deal with vfs streams and throws warnings
903  ['getMimeTypeOfFile']
904  );
905  $filterCallbacks = [
906  [
907  LocalDriverFilenameFilter::class,
908  'filterFilename',
909  ],
910  ];
911  $fileList = $subject->getFilesInFolder('/', 0, 0, false, $filterCallbacks);
912  self::assertNotContains('/fileA', array_keys($fileList));
913  }
914 
919  {
920  $dirStructure = [
921  'dir1' => [],
922  'dir2' => [],
923  'file' => 'asdfg',
924  ];
925  $this->‪addToMount($dirStructure);
926  $subject = $this->‪createDriver();
927  $fileList = $subject->getFoldersInFolder('/');
928  self::assertEquals(['/dir1/', '/dir2/'], array_keys($fileList));
929  }
930 
934  public function ‪getFolderListReturnsHiddenFoldersByDefault(): void
935  {
936  $dirStructure = [
937  '.someHiddenDir' => [],
938  'aDir' => [],
939  'file1' => '',
940  ];
941  $this->‪addToMount($dirStructure);
942  $subject = $this->‪createDriver();
943 
944  $fileList = $subject->getFoldersInFolder('/');
945 
946  self::assertEquals(['/.someHiddenDir/', '/aDir/'], array_keys($fileList));
947  }
948 
954  public function ‪getFolderListLeavesOutNavigationalEntries(): void
955  {
956  // we have to add .. and . manually, as these are not included in vfsStream directory listings (as opposed
957  // to normal filelistings)
958  $this->‪addToMount([
959  '..' => [],
960  '.' => [],
961  ]);
962  $subject = $this->‪createDriver();
963  $fileList = $subject->getFoldersInFolder('/');
964  self::assertEmpty($fileList);
965  }
966 
971  {
972  $dirStructure = [
973  'folderA' => [],
974  'folderB' => [],
975  ];
976  $this->‪addToMount($dirStructure);
977  $subject = $this->‪createDriver();
978  $filterCallbacks = [
979  [
980  LocalDriverFilenameFilter::class,
981  'filterFilename',
982  ],
983  ];
984  $folderList = $subject->getFoldersInFolder('/', 0, 0, $filterCallbacks);
985  self::assertNotContains('folderA', array_keys($folderList));
986  }
987 
991  public function ‪getFolderListFailsIfDirectoryDoesNotExist(): void
992  {
993  $this->expectException(\InvalidArgumentException::class);
994  $this->expectExceptionCode(1314349666);
995  $subject = $this->‪createDriver();
996  vfsStream::create([$this->basedir => ['somefile' => '']]);
997  $subject->getFoldersInFolder('somedir/');
998  }
999 
1003  public function ‪hashReturnsCorrectHashes(): void
1004  {
1005  $contents = '68b329da9893e34099c7d8ad5cb9c940';
1006  $expectedMd5Hash = '8c67dbaf0ba22f2e7fbc26413b86051b';
1007  $expectedSha1Hash = 'a60cd808ba7a0bcfa37fa7f3fb5998e1b8dbcd9d';
1008  $this->‪addToMount(['hashFile' => $contents]);
1009  $subject = $this->‪createDriver();
1010  self::assertEquals($expectedSha1Hash, $subject->hash('/hashFile', 'sha1'));
1011  self::assertEquals($expectedMd5Hash, $subject->hash('/hashFile', 'md5'));
1012  }
1013 
1017  public function ‪hashingWithUnsupportedAlgorithmFails(): void
1018  {
1019  $this->expectException(\InvalidArgumentException::class);
1020  $this->expectExceptionCode(1304964032);
1021  $subject = $this->‪createDriver();
1022  $subject->hash('/hashFile', ‪StringUtility::getUniqueId('uri_'));
1023  }
1024 
1030  {
1031  $fileContents = 'asdfgh';
1032  $this->‪addToMount([
1033  'someDir' => [
1034  'someFile' => $fileContents,
1035  ],
1036  ]);
1037  $subject = $this->‪createDriver([], ['copyFileToTemporaryPath']);
1038  $subject->expects(self::once())->method('copyFileToTemporaryPath');
1039  $subject->getFileForLocalProcessing('/someDir/someFile');
1040  }
1041 
1046  {
1047  $fileContents = 'asdfgh';
1048  $this->‪addToMount([
1049  'someDir' => [
1050  'someFile' => $fileContents,
1051  ],
1052  ]);
1053  $subject = $this->‪createDriver();
1054  $filePath = $subject->getFileForLocalProcessing('/someDir/someFile', false);
1055  self::assertEquals($filePath, $this->‪getUrlInMount('someDir/someFile'));
1056  }
1057 
1061  public function ‪filesCanBeCopiedToATemporaryPath(): void
1062  {
1063  $fileContents = 'asdfgh';
1064  $this->‪addToMount([
1065  'someDir' => [
1066  'someFile.ext' => $fileContents,
1067  ],
1068  ]);
1069  $subject = $this->‪createDriver();
1070  $filePath = GeneralUtility::fixWindowsFilePath($subject->_call('copyFileToTemporaryPath', '/someDir/someFile.ext'));
1071  $this->testFilesToDelete[] = $filePath;
1072  self::assertStringContainsString(‪Environment::getVarPath() . '/transient/', $filePath);
1073  self::assertEquals($fileContents, file_get_contents($filePath));
1074  }
1075 
1080  {
1082  [‪$basedir, $subject] = $this->‪prepareRealTestEnvironment();
1083  touch(‪$basedir . '/someFile');
1084  chmod(‪$basedir . '/someFile', 448);
1085  clearstatcache();
1086  self::assertEquals(['r' => true, 'w' => true], $subject->getPermissions('/someFile'));
1087  }
1088 
1093  {
1095  [‪$basedir, $subject] = $this->‪prepareRealTestEnvironment();
1096  mkdir(‪$basedir . '/someFolder');
1097  chmod(‪$basedir . '/someFolder', 448);
1098  clearstatcache();
1099  self::assertEquals(['r' => true, 'w' => true], $subject->getPermissions('/someFolder'));
1100  }
1101 
1106  {
1107  $subject = $this->‪createDriver();
1108  self::assertTrue($subject->isWithin('/someFolder/', '/someFolder/test.jpg'));
1109  self::assertTrue($subject->isWithin('/someFolder/', '/someFolder/subFolder/test.jpg'));
1110  self::assertFalse($subject->isWithin('/someFolder/', '/someFolderWithALongName/test.jpg'));
1111  }
1112 
1116  public function ‪isWithinAcceptsFileAndFolderObjectsAsContent(): void
1117  {
1118  $subject = $this->‪createDriver();
1119  self::assertTrue($subject->isWithin('/someFolder/', '/someFolder/test.jpg'));
1120  self::assertTrue($subject->isWithin('/someFolder/', '/someFolder/subfolder/'));
1121  }
1122 
1123  /**********************************
1124  * Copy/move file
1125  **********************************/
1126 
1130  public function ‪filesCanBeCopiedWithinStorage(): void
1131  {
1132  $fileContents = ‪StringUtility::getUniqueId('content_');
1133  $this->‪addToMount([
1134  'someFile' => $fileContents,
1135  'targetFolder' => [],
1136  ]);
1137  $subject = $this->‪createDriver(
1138  [],
1139  ['getMimeTypeOfFile']
1140  );
1141  $subject->copyFileWithinStorage('/someFile', '/targetFolder/', 'someFile');
1142  self::assertFileEquals($this->‪getUrlInMount('/someFile'), $this->‪getUrlInMount('/targetFolder/someFile'));
1143  }
1144 
1148  public function ‪filesCanBeMovedWithinStorage(): void
1149  {
1150  $fileContents = ‪StringUtility::getUniqueId('content_');
1151  $this->‪addToMount([
1152  'targetFolder' => [],
1153  'someFile' => $fileContents,
1154  ]);
1155  $subject = $this->‪createDriver();
1156  $newIdentifier = $subject->moveFileWithinStorage('/someFile', '/targetFolder/', 'file');
1157  self::assertEquals($fileContents, file_get_contents($this->‪getUrlInMount('/targetFolder/file')));
1158  self::assertFileDoesNotExist($this->‪getUrlInMount('/someFile'));
1159  self::assertEquals('/targetFolder/file', $newIdentifier);
1160  }
1161 
1165  public function ‪fileMetadataIsChangedAfterMovingFile(): void
1166  {
1167  $fileContents = ‪StringUtility::getUniqueId('content_');
1168  $this->‪addToMount([
1169  'targetFolder' => [],
1170  'someFile' => $fileContents,
1171  ]);
1172  $subject = $this->‪createDriver(
1173  [],
1174  // Mocked because finfo() can not deal with vfs streams and throws warnings
1175  ['getMimeTypeOfFile']
1176  );
1177  $newIdentifier = $subject->moveFileWithinStorage('/someFile', '/targetFolder/', 'file');
1178  $fileMetadata = $subject->getFileInfoByIdentifier($newIdentifier);
1179  self::assertEquals($newIdentifier, $fileMetadata['identifier']);
1180  }
1181 
1182  public function ‪renamingFiles_dataProvider(): array
1183  {
1184  return [
1185  'file in subfolder' => [
1186  [
1187  'targetFolder' => ['file' => ''],
1188  ],
1189  '/targetFolder/file',
1190  'newFile',
1191  '/targetFolder/newFile',
1192  ],
1193  'file in rootfolder' => [
1194  [
1195  'fileInRoot' => '',
1196  ],
1197  '/fileInRoot',
1198  'newFile',
1199  '/newFile',
1200  ],
1201  ];
1202  }
1203 
1212  public function ‪renamingFilesChangesFilenameOnDisk(
1213  array $filesystemStructure,
1214  string $oldFileIdentifier,
1215  string $newFileName,
1216  string $expectedNewIdentifier
1217  ): void {
1218  $this->‪addToMount($filesystemStructure);
1219  $subject = $this->‪createDriver();
1220  $newIdentifier = $subject->renameFile($oldFileIdentifier, $newFileName);
1221  self::assertFalse($subject->fileExists($oldFileIdentifier));
1222  self::assertTrue($subject->fileExists($newIdentifier));
1223  self::assertEquals($expectedNewIdentifier, $newIdentifier);
1224  }
1225 
1229  public function ‪renamingFilesFailsIfTargetFileExists(): void
1230  {
1231  $this->expectException(ExistingTargetFileNameException::class);
1232  $this->expectExceptionCode(1320291063);
1233  $this->‪addToMount([
1234  'targetFolder' => ['file' => '', 'newFile' => ''],
1235  ]);
1236  $subject = $this->‪createDriver();
1237  $subject->renameFile('/targetFolder/file', 'newFile');
1238  }
1239 
1245  public function ‪renamingFolders_dataProvider(): array
1246  {
1247  return [
1248  'folder in root folder' => [
1249  [
1250  'someFolder' => [],
1251  ],
1252  '/someFolder/',
1253  'newFolder',
1254  '/newFolder/',
1255  ],
1256  'file in subfolder' => [
1257  [
1258  'subfolder' => [
1259  'someFolder' => [],
1260  ],
1261  ],
1262  '/subfolder/someFolder/',
1263  'newFolder',
1264  '/subfolder/newFolder/',
1265  ],
1266  ];
1267  }
1268 
1278  array $filesystemStructure,
1279  string $oldFolderIdentifier,
1280  string $newFolderName,
1281  string $expectedNewIdentifier
1282  ): void {
1283  $this->‪addToMount($filesystemStructure);
1284  $subject = $this->‪createDriver();
1285  $mapping = $subject->renameFolder($oldFolderIdentifier, $newFolderName);
1286  self::assertFalse($subject->folderExists($oldFolderIdentifier));
1287  self::assertTrue($subject->folderExists($expectedNewIdentifier));
1288  self::assertEquals($expectedNewIdentifier, $mapping[$oldFolderIdentifier]);
1289  }
1290 
1295  {
1296  $fileContents = 'asdfg';
1297  $this->‪addToMount([
1298  'sourceFolder' => [
1299  'subFolder' => ['file' => $fileContents],
1300  'file2' => 'asdfg',
1301  ],
1302  ]);
1303  $subject = $this->‪createDriver();
1304  $mappingInformation = $subject->renameFolder('/sourceFolder/', 'newFolder');
1305  self::assertIsArray($mappingInformation);
1306  self::assertEquals('/newFolder/', $mappingInformation['/sourceFolder/']);
1307  self::assertEquals('/newFolder/file2', $mappingInformation['/sourceFolder/file2']);
1308  self::assertEquals('/newFolder/subFolder/file', $mappingInformation['/sourceFolder/subFolder/file']);
1309  self::assertEquals('/newFolder/subFolder/', $mappingInformation['/sourceFolder/subFolder/']);
1310  }
1311 
1316  {
1317  $this->expectException(\RuntimeException::class);
1318  $this->expectExceptionCode(1334160746);
1319  $this->‪addToMount([
1320  'sourceFolder' => [
1321  'file' => 'asdfg',
1322  ],
1323  ]);
1324  $subject = $this->‪createDriver([], ['createIdentifierMap']);
1325  $subject->expects(self::atLeastOnce())->method('createIdentifierMap')->will(
1326  self::throwException(
1327  new FileOperationErrorException('testing', 1476045666)
1328  )
1329  );
1330  $subject->renameFolder('/sourceFolder/', 'newFolder');
1331  self::assertFileExists($this->‪getUrlInMount('/sourceFolder/file'));
1332  }
1333 
1337  public function ‪isFolderEmptyReturnsTrueForEmptyFolder(): LocalDriver
1338  {
1339  // This also prepares the next few tests, so add more info than required for this test
1340  $this->‪addToMount([
1341  'emptyFolder' => [],
1342  ]);
1343  $subject = $this->‪createDriver();
1344  self::assertTrue($subject->isFolderEmpty('/emptyFolder/'));
1345  return $subject;
1346  }
1347 
1351  public function ‪isFolderEmptyReturnsFalseIfFolderHasFile(): void
1352  {
1353  $this->‪addToMount([
1354  'folderWithFile' => [
1355  'someFile' => '',
1356  ],
1357  ]);
1358  $subject = $this->‪createDriver();
1359  self::assertFalse($subject->isFolderEmpty('/folderWithFile/'));
1360  }
1361 
1365  public function ‪isFolderEmptyReturnsFalseIfFolderHasSubfolder(): void
1366  {
1367  $this->‪addToMount([
1368  'folderWithSubfolder' => [
1369  'someFolder' => [],
1370  ],
1371  ]);
1372  $subject = $this->‪createDriver();
1373  self::assertFalse($subject->isFolderEmpty('/folderWithSubfolder/'));
1374  }
1375 
1376  /**********************************
1377  * Copy/move folder
1378  **********************************/
1382  public function ‪foldersCanBeMovedWithinStorage(): void
1383  {
1384  $fileContents = ‪StringUtility::getUniqueId('content_');
1385  $this->‪addToMount([
1386  'sourceFolder' => [
1387  'file' => $fileContents,
1388  ],
1389  'targetFolder' => [],
1390  ]);
1391  $subject = $this->‪createDriver();
1393  $subject->moveFolderWithinStorage('/sourceFolder/', '/targetFolder/', 'someFolder');
1394  self::assertFileExists($this->‪getUrlInMount('/targetFolder/someFolder/'));
1395  self::assertEquals($fileContents, file_get_contents($this->‪getUrlInMount('/targetFolder/someFolder/file')));
1396  self::assertFileDoesNotExist($this->‪getUrlInMount('/sourceFolder'));
1397  }
1398 
1403  {
1404  $fileContents = 'asdfg';
1405  $this->‪addToMount([
1406  'targetFolder' => [],
1407  'sourceFolder' => [
1408  'subFolder' => ['file' => $fileContents],
1409  'file' => 'asdfg',
1410  ],
1411  ]);
1412  $subject = $this->‪createDriver();
1413  $mappingInformation = $subject->moveFolderWithinStorage('/sourceFolder/', '/targetFolder/', 'sourceFolder');
1414  self::assertEquals('/targetFolder/sourceFolder/file', $mappingInformation['/sourceFolder/file']);
1415  self::assertEquals(
1416  '/targetFolder/sourceFolder/subFolder/file',
1417  $mappingInformation['/sourceFolder/subFolder/file']
1418  );
1419  self::assertEquals('/targetFolder/sourceFolder/subFolder/', $mappingInformation['/sourceFolder/subFolder/']);
1420  }
1421 
1425  public function ‪folderCanBeRenamedWhenMoving(): void
1426  {
1427  $this->‪addToMount([
1428  'sourceFolder' => [
1429  'file' => ‪StringUtility::getUniqueId('content_'),
1430  ],
1431  'targetFolder' => [],
1432  ]);
1433  $subject = $this->‪createDriver();
1434  $subject->moveFolderWithinStorage('/sourceFolder/', '/targetFolder/', 'newFolder');
1435  self::assertFileExists($this->‪getUrlInMount('/targetFolder/newFolder/'));
1436  }
1437 
1442  {
1443  $this->‪addToMount([
1444  'sourceFolder' => [
1445  'file' => ‪StringUtility::getUniqueId('name_'),
1446  ],
1447  'targetFolder' => [],
1448  ]);
1449  $subject = $this->‪createDriver();
1450  $subject->copyFolderWithinStorage('/sourceFolder/', '/targetFolder/', 'newFolderName');
1451  self::assertTrue(is_file($this->‪getUrlInMount('/targetFolder/newFolderName/file')));
1452  }
1453 
1458  {
1459  [$basePath, $subject] = $this->‪prepareRealTestEnvironment();
1460  ‪GeneralUtility::mkdir_deep($basePath . '/sourceFolder/subFolder');
1461  ‪GeneralUtility::mkdir_deep($basePath . '/targetFolder');
1462 
1463  $subject->copyFolderWithinStorage('/sourceFolder/', '/targetFolder/', 'newFolderName');
1464  self::assertDirectoryExists($basePath . '/targetFolder/newFolderName/subFolder');
1465  }
1466 
1471  {
1472  [$basePath, $subject] = $this->‪prepareRealTestEnvironment();
1473  ‪GeneralUtility::mkdir_deep($basePath . '/sourceFolder/subFolder');
1474  ‪GeneralUtility::mkdir_deep($basePath . '/targetFolder');
1475  file_put_contents($basePath . '/sourceFolder/subFolder/file', ‪StringUtility::getUniqueId('content_'));
1476  ‪GeneralUtility::fixPermissions($basePath . '/sourceFolder/subFolder/file');
1477 
1478  $subject->copyFolderWithinStorage('/sourceFolder/', '/targetFolder/', 'newFolderName');
1479  self::assertTrue(is_file($basePath . '/targetFolder/newFolderName/subFolder/file'));
1480  }
1481 
1483  // Tests concerning sanitizeFileName
1485 
1489  public function ‪setUpCharacterStrings(): void
1490  {
1491  // Generate string containing all characters for the iso8859-1 charset, charcode greater than 127
1492  $this->iso88591GreaterThan127 = '';
1493  for ($i = 0xA0; $i <= 0xFF; $i++) {
1494  $this->iso88591GreaterThan127 .= chr($i);
1495  }
1496 
1497  // Generate string containing all characters for the utf-8 Latin-1 Supplement (U+0080 to U+00FF)
1498  // without U+0080 to U+009F: control characters
1499  // Based on http://www.utf8-chartable.de/unicode-utf8-table.pl
1500  $this->utf8Latin1Supplement = '';
1501  for ($i = 0xA0; $i <= 0xBF; $i++) {
1502  $this->utf8Latin1Supplement .= chr(0xC2) . chr($i);
1503  }
1504  for ($i = 0x80; $i <= 0xBF; $i++) {
1505  $this->utf8Latin1Supplement .= chr(0xC3) . chr($i);
1506  }
1507 
1508  // Generate string containing all characters for the utf-8 Latin-1 Extended-A (U+0100 to U+017F)
1509  $this->utf8Latin1ExtendedA = '';
1510  for ($i = 0x80; $i <= 0xBF; $i++) {
1511  $this->utf8Latin1ExtendedA .= chr(0xC4) . chr($i);
1512  }
1513  for ($i = 0x80; $i <= 0xBF; $i++) {
1514  $this->utf8Latin1ExtendedA .= chr(0xC5) . chr($i);
1515  }
1516  }
1517 
1528  public function ‪sanitizeFileNameUTF8FilesystemDataProvider(): array
1529  {
1530  $this->‪setUpCharacterStrings();
1531  return [
1532  // Characters ordered by ASCII table
1533  'allowed characters utf-8 (ASCII part)' => [
1534  '-.0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz',
1535  '-.0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz',
1536  ],
1537  // Characters ordered by ASCII table (except for space-character, because space-character ist trimmed)
1538  'replace special characters with _ (not allowed characters) utf-8 (ASCII part)' => [
1539  '! "#$%&\'()*+,/:;<=>?[\\]^`{|}~',
1540  '_____________________________',
1541  ],
1542  'utf-8 (Latin-1 Supplement)' => [
1544  '________________________________ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ',
1545  ],
1546  'utf-8 but not in NFC (Canonical Composition)' => [
1547  hex2bin('667275cc88686e65757a6569746c696368656e'),
1548  'frühneuzeitlichen',
1549  ],
1550  'trim leading and tailing spaces utf-8' => [
1551  ' test.txt ',
1552  'test.txt',
1553  ],
1554  'remove tailing dot' => [
1555  'test.txt.',
1556  'test.txt',
1557  ],
1558  ];
1559  }
1560 
1567  public function ‪sanitizeFileNameUTF8Filesystem(string $fileName, string $expectedResult): void
1568  {
1569  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['UTF8filesystem'] = 1;
1570  self::assertEquals(
1571  $expectedResult,
1572  $this->‪createDriver()->sanitizeFileName($fileName)
1573  );
1574  }
1575 
1586  public function ‪sanitizeFileNameNonUTF8FilesystemDataProvider(): array
1587  {
1588  $this->‪setUpCharacterStrings();
1589  return [
1590  // Characters ordered by ASCII table
1591  'allowed characters iso-8859-1' => [
1592  '-.0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz',
1593  'iso-8859-1',
1594  '-.0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz',
1595  ],
1596  // Characters ordered by ASCII table
1597  'allowed characters utf-8' => [
1598  '-.0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz',
1599  'utf-8',
1600  '-.0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz',
1601  ],
1602  // Characters ordered by ASCII table (except for space-character, because space-character ist trimmed)
1603  'replace special characters with _ (not allowed characters) iso-8859-1' => [
1604  '! "#$%&\'()*+,/:;<=>?[\\]^`{|}~',
1605  'iso-8859-1',
1606  '_____________________________',
1607  ],
1608  // Characters ordered by ASCII table (except for space-character, because space-character ist trimmed)
1609  'replace special characters with _ (not allowed characters) utf-8' => [
1610  '! "#$%&\'()*+,/:;<=>?[\\]^`{|}~',
1611  'utf-8',
1612  '_____________________________',
1613  ],
1614  'iso-8859-1 (code > 127)' => [
1615  // http://de.wikipedia.org/wiki/ISO_8859-1
1616  // chr(0xA0) = NBSP (no-break space) => gets trimmed
1618  'iso-8859-1',
1619  '_centpound_yen____c_a_____R_____-23_u___1o__1_41_23_4_AAAAAEAAAECEEEEIIIIDNOOOOOExOEUUUUEYTHssaaaaaeaaaeceeeeiiiidnoooooe_oeuuuueythy',
1620  ],
1621  'utf-8 (Latin-1 Supplement)' => [
1622  // chr(0xC2) . chr(0x0A) = NBSP (no-break space) => gets trimmed
1624  'utf-8',
1625  '_centpound__yen______c_a_______R_______-23__u_____1o__1_41_23_4_AAAAAEAAAECEEEEIIIIDNOOOOOExOEUUUUEYTHssaaaaaeaaaeceeeeiiiidnoooooe_oeuuuueythy',
1626  ],
1627  'utf-8 (Latin-1 Extended A)' => [
1629  'utf-8',
1630  'AaAaAaCcCcCcCcDdDdEeEeEeEeEeGgGgGgGgHhHhIiIiIiIiIiIJijJjKk__LlLlLlL_l_LlNnNnNn_n____OOooOoOoOEoeRrRrRrSsSsSsSsTtTtTtUuUuUuUuUuUuWwYyYZzZzZzs',
1631  ],
1632  'utf-8 but not in NFC (Canonical Composition)' => [
1633  hex2bin('667275cc88686e65757a6569746c696368656e'),
1634  'utf-8',
1635  'fruehneuzeitlichen',
1636  ],
1637  'trim leading and tailing spaces iso-8859-1' => [
1638  ' test.txt ',
1639  'iso-8859-1',
1640  'test.txt',
1641  ],
1642  'trim leading and tailing spaces utf-8' => [
1643  ' test.txt ',
1644  'utf-8',
1645  'test.txt',
1646  ],
1647  'remove tailing dot iso-8859-1' => [
1648  'test.txt.',
1649  'iso-8859-1',
1650  'test.txt',
1651  ],
1652  'remove tailing dot utf-8' => [
1653  'test.txt.',
1654  'utf-8',
1655  'test.txt',
1656  ],
1657  ];
1658  }
1659 
1667  public function ‪sanitizeFileNameNonUTF8Filesystem(string $fileName, string $charset, string $expectedResult): void
1668  {
1669  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['UTF8filesystem'] = 0;
1670  self::assertEquals(
1671  $expectedResult,
1672  $this->‪createDriver()->sanitizeFileName($fileName, $charset)
1673  );
1674  }
1675 
1680  {
1681  $this->expectException(InvalidFileNameException::class);
1682  $this->expectExceptionCode(1320288991);
1683 
1684  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['UTF8filesystem'] = 1;
1685  $this->‪createDriver()->‪sanitizeFileName('');
1686  }
1687 
1692  {
1693  $this->expectException(\Exception::class);
1694  $this->expectExceptionCode(1463073434);
1695  $closure = static function () {
1696  throw new \Exception('I was called!', 1463073434);
1697  };
1698 
1699  $filterMethods = [
1700  $closure,
1701  ];
1702 
1703  $this->‪createDriver()->_call('applyFilterMethodsToDirectoryItem', $filterMethods, '', '', '');
1704  }
1705 
1710  {
1711  $dummyObject = $this
1712  ->getMockBuilder(LocalDriver::class)
1713  ->addMethods(['dummy'])
1714  ->disableOriginalConstructor()
1715  ->getMock();
1716  $method = [
1717  $dummyObject,
1718  'dummy',
1719  ];
1720  $dummyObject->expects(self::once())->method('dummy');
1721  $filterMethods = [
1722  $method,
1723  ];
1724  $this->‪createDriver()->_call('applyFilterMethodsToDirectoryItem', $filterMethods, '', '', '');
1725  }
1726 }
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\sanitizeFileNameNonUTF8FilesystemDataProvider
‪array sanitizeFileNameNonUTF8FilesystemDataProvider()
Definition: LocalDriverTest.php:1584
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getPublicUrlReturnsValidUrlContainingSpecialCharacters_dataProvider
‪array getPublicUrlReturnsValidUrlContainingSpecialCharacters_dataProvider()
Definition: LocalDriverTest.php:637
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getFilesInFolderReturnsEmptyArrayForEmptyDirectory
‪getFilesInFolderReturnsEmptyArrayForEmptyDirectory()
Definition: LocalDriverTest.php:785
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\sanitizeFileNameNonUTF8Filesystem
‪sanitizeFileNameNonUTF8Filesystem(string $fileName, string $charset, string $expectedResult)
Definition: LocalDriverTest.php:1665
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\$iso88591GreaterThan127
‪string $iso88591GreaterThan127
Definition: LocalDriverTest.php:47
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\$utf8Latin1Supplement
‪string $utf8Latin1Supplement
Definition: LocalDriverTest.php:48
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\sanitizeFileNameUTF8FilesystemDataProvider
‪array sanitizeFileNameUTF8FilesystemDataProvider()
Definition: LocalDriverTest.php:1526
‪TYPO3\CMS\Core\Resource\ResourceStorageInterface
Definition: ResourceStorageInterface.php:22
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getSpecificFileInformationDataProvider
‪array getSpecificFileInformationDataProvider()
Definition: LocalDriverTest.php:413
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getPublicUrlReturnsValidUrlContainingSpecialCharacters
‪getPublicUrlReturnsValidUrlContainingSpecialCharacters(string $fileIdentifier)
Definition: LocalDriverTest.php:652
‪TYPO3\CMS\Core\Core\Environment\getPublicPath
‪static string getPublicPath()
Definition: Environment.php:206
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\$testDirs
‪array $testDirs
Definition: LocalDriverTest.php:46
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\filesCanBeCopiedWithinStorage
‪filesCanBeCopiedWithinStorage()
Definition: LocalDriverTest.php:1128
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\fileContentsCanBeWrittenAndRead
‪fileContentsCanBeWrittenAndRead()
Definition: LocalDriverTest.php:668
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\permissionsAreCorrectlyRetrievedForAllowedFile
‪permissionsAreCorrectlyRetrievedForAllowedFile()
Definition: LocalDriverTest.php:1077
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getFolderInFolderReturnsCorrectFolderObject
‪getFolderInFolderReturnsCorrectFolderObject()
Definition: LocalDriverTest.php:326
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver
Definition: LocalDriver.php:41
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\$backupEnvironment
‪bool $backupEnvironment
Definition: LocalDriverTest.php:43
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getFileInFolderCallsConfiguredCallbackFunctionWithGivenItemName
‪getFileInFolderCallsConfiguredCallbackFunctionWithGivenItemName()
Definition: LocalDriverTest.php:852
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\copyFolderWithinStorageCopiesFileInSingleSubFolderToNewFolderName
‪copyFolderWithinStorageCopiesFileInSingleSubFolderToNewFolderName()
Definition: LocalDriverTest.php:1468
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\copyFolderWithinStorageCopiesSingleFileToNewFolderName
‪copyFolderWithinStorageCopiesSingleFileToNewFolderName()
Definition: LocalDriverTest.php:1439
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\filesCanBeCopiedToATemporaryPath
‪filesCanBeCopiedToATemporaryPath()
Definition: LocalDriverTest.php:1059
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\isFolderEmptyReturnsFalseIfFolderHasFile
‪isFolderEmptyReturnsFalseIfFolderHasFile()
Definition: LocalDriverTest.php:1349
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getPublicUrlReturnsCorrectUriForConfiguredBaseUri
‪getPublicUrlReturnsCorrectUriForConfiguredBaseUri()
Definition: LocalDriverTest.php:616
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getDefaultFolderReturnsFolderForUserUploadPath
‪getDefaultFolderReturnsFolderForUserUploadPath()
Definition: LocalDriverTest.php:307
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\fileMetadataIsChangedAfterMovingFile
‪fileMetadataIsChangedAfterMovingFile()
Definition: LocalDriverTest.php:1163
‪TYPO3\CMS\Core\Core\Environment\isUnix
‪static bool isUnix()
Definition: Environment.php:328
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getFileListReturnsAllFilesInSubdirectoryIfRecursiveParameterIsSet
‪getFileListReturnsAllFilesInSubdirectoryIfRecursiveParameterIsSet()
Definition: LocalDriverTest.php:815
‪TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCase
Definition: BaseTestCase.php:31
‪TYPO3\CMS\Core\Core\Environment\isWindows
‪static bool isWindows()
Definition: Environment.php:318
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\isFolderEmptyReturnsFalseIfFolderHasSubfolder
‪isFolderEmptyReturnsFalseIfFolderHasSubfolder()
Definition: LocalDriverTest.php:1363
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\renamingFolders_dataProvider
‪array renamingFolders_dataProvider()
Definition: LocalDriverTest.php:1243
‪TYPO3\CMS\Core\Core\Environment\getCurrentScript
‪static string getCurrentScript()
Definition: Environment.php:246
‪TYPO3\CMS\Core\Resource\Exception\ExistingTargetFileNameException
Definition: ExistingTargetFileNameException.php:23
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\addFileReturnsFileIdentifier
‪addFileReturnsFileIdentifier()
Definition: LocalDriverTest.php:560
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\renamingFilesFailsIfTargetFileExists
‪renamingFilesFailsIfTargetFileExists()
Definition: LocalDriverTest.php:1227
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\isFolderEmptyReturnsTrueForEmptyFolder
‪isFolderEmptyReturnsTrueForEmptyFolder()
Definition: LocalDriverTest.php:1335
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\setUpCharacterStrings
‪setUpCharacterStrings()
Definition: LocalDriverTest.php:1487
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\isWithinAcceptsFileAndFolderObjectsAsContent
‪isWithinAcceptsFileAndFolderObjectsAsContent()
Definition: LocalDriverTest.php:1114
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\determineBaseUrlUrlEncodesUriParts
‪determineBaseUrlUrlEncodesUriParts()
Definition: LocalDriverTest.php:283
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\createFolderSanitizesFolderNameBeforeCreation
‪createFolderSanitizesFolderNameBeforeCreation(string $newFolderName, string $expectedFolderName)
Definition: LocalDriverTest.php:384
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\newFilesCanBeCreated
‪newFilesCanBeCreated()
Definition: LocalDriverTest.php:704
‪$dir
‪$dir
Definition: validateRstFiles.php:213
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\createRealTestdir
‪string createRealTestdir()
Definition: LocalDriverTest.php:71
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\createFolderCreatesFolderOnDisk
‪createFolderCreatesFolderOnDisk()
Definition: LocalDriverTest.php:341
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\addFileFailsIfFileIsInDriverStorage
‪addFileFailsIfFileIsInDriverStorage()
Definition: LocalDriverTest.php:544
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\$resetSingletonInstances
‪bool $resetSingletonInstances
Definition: LocalDriverTest.php:39
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getFolderListFailsIfDirectoryDoesNotExist
‪getFolderListFailsIfDirectoryDoesNotExist()
Definition: LocalDriverTest.php:989
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\foldersCanBeMovedWithinStorage
‪foldersCanBeMovedWithinStorage()
Definition: LocalDriverTest.php:1380
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\applyFilterMethodsToDirectoryItemCallsFilterMethodIfClosure
‪applyFilterMethodsToDirectoryItemCallsFilterMethodIfClosure()
Definition: LocalDriverTest.php:1689
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\hashReturnsCorrectHashes
‪hashReturnsCorrectHashes()
Definition: LocalDriverTest.php:1001
‪TYPO3\CMS\Core\Core\Environment\getContext
‪static ApplicationContext getContext()
Definition: Environment.php:141
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver
Definition: AbstractDriverTest.php:18
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\applyFilterMethodsToDirectoryItemCallsFilterMethodIfName
‪applyFilterMethodsToDirectoryItemCallsFilterMethodIfName()
Definition: LocalDriverTest.php:1707
‪TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCase\addToVfs
‪addToVfs(array $dirStructure)
Definition: BaseTestCase.php:84
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\calculatedBasePathAbsoluteIsSane
‪calculatedBasePathAbsoluteIsSane()
Definition: LocalDriverTest.php:146
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getFileForLocalProcessingCreatesCopyOfFileByDefault
‪getFileForLocalProcessingCreatesCopyOfFileByDefault()
Definition: LocalDriverTest.php:1027
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\hashingWithUnsupportedAlgorithmFails
‪hashingWithUnsupportedAlgorithmFails()
Definition: LocalDriverTest.php:1015
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\createdFilesAreEmpty
‪createdFilesAreEmpty()
Definition: LocalDriverTest.php:715
‪TYPO3\CMS\Core\Core\Environment\getProjectPath
‪static string getProjectPath()
Definition: Environment.php:177
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\renameFolderReturnsCorrectMappingInformationForAllFiles
‪renameFolderReturnsCorrectMappingInformationForAllFiles()
Definition: LocalDriverTest.php:1292
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getAbsolutePathReturnsCorrectPath
‪getAbsolutePathReturnsCorrectPath()
Definition: LocalDriverTest.php:488
‪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:1749
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\createFileFixesPermissionsOnCreatedFile
‪createFileFixesPermissionsOnCreatedFile()
Definition: LocalDriverTest.php:727
‪TYPO3\CMS\Core\Utility\GeneralUtility\mkdir_deep
‪static mkdir_deep($directory)
Definition: GeneralUtility.php:1908
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getFileThrowsExceptionIfFileDoesNotExist
‪getFileThrowsExceptionIfFileDoesNotExist()
Definition: LocalDriverTest.php:774
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\callbackStaticTestFunction
‪static callbackStaticTestFunction(string $itemName)
Definition: LocalDriverTest.php:881
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\folderCanBeRenamedWhenMoving
‪folderCanBeRenamedWhenMoving()
Definition: LocalDriverTest.php:1423
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\defaultLevelFolderFolderIsCreatedIfItDoesntExist
‪defaultLevelFolderFolderIsCreatedIfItDoesntExist()
Definition: LocalDriverTest.php:317
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\existenceChecksInFolderWorkForFilesAndFolders
‪existenceChecksInFolderWorkForFilesAndFolders()
Definition: LocalDriverTest.php:598
‪TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCase\getMountRootUrl
‪getMountRootUrl()
Definition: BaseTestCase.php:46
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\sanitizeFileNameThrowsExceptionOnInvalidFileName
‪sanitizeFileNameThrowsExceptionOnInvalidFileName()
Definition: LocalDriverTest.php:1677
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\$localDriver
‪LocalDriver $localDriver
Definition: LocalDriverTest.php:45
‪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:111
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\existenceChecksWorkForFilesAndFolders
‪existenceChecksWorkForFilesAndFolders()
Definition: LocalDriverTest.php:581
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\permissionsAreCorrectlyRetrievedForAllowedFolder
‪permissionsAreCorrectlyRetrievedForAllowedFolder()
Definition: LocalDriverTest.php:1090
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\setFileContentsReturnsNumberOfBytesWrittenToFile
‪setFileContentsReturnsNumberOfBytesWrittenToFile()
Definition: LocalDriverTest.php:688
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getFileForLocalProcessingReturnsOriginalFilepathForReadonlyAccess
‪getFileForLocalProcessingReturnsOriginalFilepathForReadonlyAccess()
Definition: LocalDriverTest.php:1043
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\$utf8Latin1ExtendedA
‪string $utf8Latin1ExtendedA
Definition: LocalDriverTest.php:49
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\prepareRealTestEnvironment
‪array prepareRealTestEnvironment()
Definition: LocalDriverTest.php:85
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\addFileUsesFilenameIfGiven
‪addFileUsesFilenameIfGiven()
Definition: LocalDriverTest.php:524
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\createFolderSanitizesFolderNameBeforeCreationDataProvider
‪static array createFolderSanitizesFolderNameBeforeCreationDataProvider()
Definition: LocalDriverTest.php:364
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\copyFolderWithinStorageCopiesSingleSubFolderToNewFolderName
‪copyFolderWithinStorageCopiesSingleSubFolderToNewFolderName()
Definition: LocalDriverTest.php:1455
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getFolderListReturnsAllDirectoriesInDirectory
‪getFolderListReturnsAllDirectoriesInDirectory()
Definition: LocalDriverTest.php:916
‪TYPO3\CMS\Core\Utility\GeneralUtility\isValidUrl
‪static bool isValidUrl($url)
Definition: GeneralUtility.php:883
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\isWithinRecognizesFilesWithinFolderAndInOtherFolders
‪isWithinRecognizesFilesWithinFolderAndInOtherFolders()
Definition: LocalDriverTest.php:1103
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\addFileMovesFileToCorrectLocation
‪addFileMovesFileToCorrectLocation()
Definition: LocalDriverTest.php:504
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\calculatedBasePathRelativeIsSane
‪calculatedBasePathRelativeIsSane()
Definition: LocalDriverTest.php:129
‪TYPO3\CMS\Core\Resource\ResourceStorage
Definition: ResourceStorage.php:125
‪TYPO3\CMS\Core\Utility\StringUtility\getUniqueId
‪static string getUniqueId($prefix='')
Definition: StringUtility.php:128
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\renamingFoldersChangesFolderNameOnDisk
‪renamingFoldersChangesFolderNameOnDisk(array $filesystemStructure, string $oldFolderIdentifier, string $newFolderName, string $expectedNewIdentifier)
Definition: LocalDriverTest.php:1275
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getFileListReturnsAllFilesInDirectory
‪getFileListReturnsAllFilesInDirectory()
Definition: LocalDriverTest.php:795
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getFolderListFiltersItemsWithGivenFilterMethods
‪getFolderListFiltersItemsWithGivenFilterMethods()
Definition: LocalDriverTest.php:968
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\noSecondSlashIsAddedIfBasePathAlreadyHasTrailingSlash
‪noSecondSlashIsAddedIfBasePathAlreadyHasTrailingSlash()
Definition: LocalDriverTest.php:404
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\createDriver
‪LocalDriver MockObject AccessibleObjectInterface createDriver(array $driverConfiguration=[], array $mockedDriverMethods=[])
Definition: LocalDriverTest.php:101
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\basePathIsNormalizedWithTrailingSlash
‪basePathIsNormalizedWithTrailingSlash()
Definition: LocalDriverTest.php:395
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getFileReturnsCorrectIdentifier
‪getFileReturnsCorrectIdentifier()
Definition: LocalDriverTest.php:755
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getFileListFailsIfDirectoryDoesNotExist
‪getFileListFailsIfDirectoryDoesNotExist()
Definition: LocalDriverTest.php:840
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:43
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest
Definition: LocalDriverTest.php:36
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\filesCanBeMovedWithinStorage
‪filesCanBeMovedWithinStorage()
Definition: LocalDriverTest.php:1146
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\tearDown
‪tearDown()
Definition: LocalDriverTest.php:54
‪TYPO3\CMS\Core\Utility\GeneralUtility\rmdir
‪static bool rmdir($path, $removeNonEmpty=false)
Definition: GeneralUtility.php:1961
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\renamingFiles_dataProvider
‪renamingFiles_dataProvider()
Definition: LocalDriverTest.php:1180
‪TYPO3\CMS\Core\Core\Environment\getConfigPath
‪static string getConfigPath()
Definition: Environment.php:236
‪TYPO3\CMS\Core\Resource\ResourceStorageInterface\CAPABILITY_PUBLIC
‪const CAPABILITY_PUBLIC
Definition: ResourceStorageInterface.php:30
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\createFolderRecursiveSanitizesFilename
‪createFolderRecursiveSanitizesFilename()
Definition: LocalDriverTest.php:268
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\sanitizeFileNameUTF8Filesystem
‪sanitizeFileNameUTF8Filesystem(string $fileName, string $expectedResult)
Definition: LocalDriverTest.php:1565
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\moveFolderWithinStorageReturnsCorrectMappingInformationForAllFiles
‪moveFolderWithinStorageReturnsCorrectMappingInformationForAllFiles()
Definition: LocalDriverTest.php:1400
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\Fixtures\LocalDriverFilenameFilter
Definition: LocalDriverFilenameFilter.php:26
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Core\Resource\Exception\FileOperationErrorException
Definition: FileOperationErrorException.php:21
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getFileListFiltersItemsWithGivenFilterMethods
‪getFileListFiltersItemsWithGivenFilterMethods()
Definition: LocalDriverTest.php:891
‪TYPO3\CMS\Core\Utility\StringUtility
Definition: StringUtility.php:22
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getFolderListLeavesOutNavigationalEntries
‪getFolderListLeavesOutNavigationalEntries()
Definition: LocalDriverTest.php:952
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\publicUrlIsCalculatedCorrectlyWithDifferentBasePathsAndBasUrisDataProvider
‪publicUrlIsCalculatedCorrectlyWithDifferentBasePathsAndBasUrisDataProvider()
Definition: LocalDriverTest.php:163
‪TYPO3\CMS\Core\Resource\Driver\LocalDriver\sanitizeFileName
‪string sanitizeFileName($fileName, $charset='utf-8')
Definition: LocalDriver.php:317
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\renamingFilesChangesFilenameOnDisk
‪renamingFilesChangesFilenameOnDisk(array $filesystemStructure, string $oldFileIdentifier, string $newFileName, string $expectedNewIdentifier)
Definition: LocalDriverTest.php:1210
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\createFolderReturnsFolderObject
‪createFolderReturnsFolderObject()
Definition: LocalDriverTest.php:353
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getFolderListReturnsHiddenFoldersByDefault
‪getFolderListReturnsHiddenFoldersByDefault()
Definition: LocalDriverTest.php:932
‪TYPO3\CMS\Core\Resource\Exception\InvalidFileNameException
Definition: InvalidFileNameException.php:23
‪TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCase\getUrlInMount
‪getUrlInMount(string $path)
Definition: BaseTestCase.php:74
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\publicUrlIsCalculatedCorrectlyWithDifferentBasePathsAndBasUris
‪publicUrlIsCalculatedCorrectlyWithDifferentBasePathsAndBasUris(string $basePath, string $baseUri, string $fileName, bool $expectedIsPublic, ?string $expectedPublicUrl)
Definition: LocalDriverTest.php:227
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\getSpecificFileInformationReturnsRequestedFileInformation
‪getSpecificFileInformationReturnsRequestedFileInformation($expectedValue, string $property)
Definition: LocalDriverTest.php:465
‪TYPO3\CMS\Core\Tests\Unit\Resource\Driver\LocalDriverTest\renameFolderRevertsRenamingIfFilenameMapCannotBeCreated
‪renameFolderRevertsRenamingIfFilenameMapCannotBeCreated()
Definition: LocalDriverTest.php:1313
‪TYPO3\CMS\Core\Core\Environment\getVarPath
‪static string getVarPath()
Definition: Environment.php:218
‪TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCase\addToMount
‪addToMount(array $dirStructure)
Definition: BaseTestCase.php:66
‪TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCase\initializeVfs
‪initializeVfs()
Definition: BaseTestCase.php:56
‪TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCase\getUrl
‪getUrl(string $path)
Definition: BaseTestCase.php:92