‪TYPO3CMS  ‪main
StorageRepositoryTest.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 
33 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
34 
35 class ‪StorageRepositoryTest extends FunctionalTestCase
36 {
37  protected function ‪tearDown(): void
38  {
40  mkdir(‪Environment::getPublicPath() . '/fileadmin');
41  ‪GeneralUtility::rmdir(‪Environment::getPublicPath() . '/typo3temp/assets/_processed_', true);
42  parent::tearDown();
43  }
44 
45  public static function ‪bestStorageIsResolvedDataProvider(): iterable
46  {
47  // `{public}` will be replaced by public project path (not having trailing slash)
48  // double slashes `//` are used on purpose for given file identifiers
49 
50  // legacy storage
51  yield ['/favicon.ico', '0:/favicon.ico'];
52  yield ['/favicon.ico', '0:/favicon.ico'];
53 
54  yield ['favicon.ico', '0:/favicon.ico'];
55  yield ['{public}//favicon.ico', '0:/favicon.ico'];
56  yield ['{public}/favicon.ico', '0:/favicon.ico'];
57 
58  // using storages with relative path
59  yield ['/fileadmin/img.png', '1:/img.png'];
60  yield ['fileadmin/img.png', '1:/img.png'];
61  yield ['/fileadmin/images/img.png', '1:/images/img.png'];
62  yield ['fileadmin/images/img.png', '1:/images/img.png'];
63  yield ['/documents/doc.pdf', '2:/doc.pdf'];
64  yield ['documents/doc.pdf', '2:/doc.pdf'];
65  yield ['/fileadmin/nested/images/img.png', '3:/images/img.png'];
66  yield ['fileadmin/nested/images/img.png', '3:/images/img.png'];
67 
68  yield ['{public}//fileadmin/img.png', '1:/img.png'];
69  yield ['{public}/fileadmin/img.png', '1:/img.png'];
70  yield ['{public}//fileadmin/images/img.png', '1:/images/img.png'];
71  yield ['{public}/fileadmin/images/img.png', '1:/images/img.png'];
72  yield ['{public}//documents/doc.pdf', '2:/doc.pdf'];
73  yield ['{public}/documents/doc.pdf', '2:/doc.pdf'];
74  yield ['{public}//fileadmin/nested/images/img.png', '3:/images/img.png'];
75  yield ['{public}/fileadmin/nested/images/img.png', '3:/images/img.png'];
76 
77  // using storages with absolute path
78  yield ['/files/img.png', '4:/img.png'];
79  yield ['files/img.png', '4:/img.png'];
80  yield ['/files/images/img.png', '4:/images/img.png'];
81  yield ['files/images/img.png', '4:/images/img.png'];
82  yield ['/docs/doc.pdf', '5:/doc.pdf'];
83  yield ['docs/doc.pdf', '5:/doc.pdf'];
84  yield ['/files/nested/images/img.png', '6:/images/img.png'];
85  yield ['files/nested/images/img.png', '6:/images/img.png'];
86 
87  yield ['{public}//files/img.png', '4:/img.png'];
88  yield ['{public}/files/img.png', '4:/img.png'];
89  yield ['{public}//files/images/img.png', '4:/images/img.png'];
90  yield ['{public}/files/images/img.png', '4:/images/img.png'];
91  yield ['{public}//docs/doc.pdf', '5:/doc.pdf'];
92  yield ['{public}/docs/doc.pdf', '5:/doc.pdf'];
93  yield ['{public}//files/nested/images/img.png', '6:/images/img.png'];
94  yield ['{public}/files/nested/images/img.png', '6:/images/img.png'];
95  }
96 
101  public function ‪bestStorageIsResolved(string $sourceIdentifier, string $expectedCombinedIdentifier): void
102  {
103  $subject = GeneralUtility::makeInstance(StorageRepository::class);
104  $this->importCSVDataSet(__DIR__ . '/../Fixtures/be_users.csv');
105  $this->setUpBackendUser(1);
106  $publicPath = ‪Environment::getPublicPath();
107  $prefixDelegate = static function (string $value) use ($publicPath): string {
108  return $publicPath . '/' . $value;
109  };
110  // array indexes are not relevant here, but are those expected to be used as storage UID (`1:/file.png`)
111  // @todo it is possible to create ambiguous storages, e.g. `fileadmin/` AND `/fileadmin/`
112  $relativeNames = [1 => 'fileadmin/', 2 => 'documents/', 3 => 'fileadmin/nested/'];
113  // @todo: All these directories must exist. This is because createLocalStorage() calls testCaseSensitivity()
114  // which creates a file in each directory without checking if the directory does exist. Arguably, this
115  // should be handled in testCaseSensitivity(). For now, we create the directories in question and
116  // suppress errors so only the first test creates them and subsequent tests don't emit a warning here.
117  @mkdir($this->instancePath . '/documents');
118  @mkdir($this->instancePath . '/fileadmin/nested');
119  $absoluteNames = array_map($prefixDelegate, [4 => 'files/', 5 => 'docs/', 6 => 'files/nested']);
120  @mkdir($this->instancePath . '/files');
121  @mkdir($this->instancePath . '/docs');
122  @mkdir($this->instancePath . '/files/nested');
123  foreach ($relativeNames as $relativeName) {
124  $subject->createLocalStorage('rel:' . $relativeName, $relativeName, 'relative');
125  }
126  foreach ($absoluteNames as $absoluteName) {
127  $subject->createLocalStorage('abs:' . $absoluteName, $absoluteName, 'absolute');
128  }
129  $sourceIdentifier = str_replace('{public}', ‪Environment::getPublicPath(), $sourceIdentifier);
130  $storage = $subject->getStorageObject(0, [], $sourceIdentifier);
131  $combinedIdentifier = sprintf('%d:%s', $storage->getUid(), $sourceIdentifier);
132  self::assertSame(
133  $expectedCombinedIdentifier,
134  $combinedIdentifier,
135  sprintf('Given identifier "%s"', $sourceIdentifier)
136  );
137  }
138 
142  public function ‪getNestedProcessingFolderTest(): void
143  {
144  $this->importCSVDataSet(__DIR__ . '/../Fixtures/sys_file_storage.csv');
145  $this->importCSVDataSet(__DIR__ . '/../Fixtures/be_users.csv');
146  $this->setUpBackendUser(1);
147  $subject = GeneralUtility::makeInstance(StorageRepository::class)->findByUid(1);
148  $subject->setEvaluatePermissions(false);
149  mkdir(‪Environment::getPublicPath() . '/fileadmin/_processed_');
150  mkdir(‪Environment::getPublicPath() . '/fileadmin/aDirectory');
151  mkdir(‪Environment::getPublicPath() . '/typo3temp/assets/_processed_');
152  file_put_contents(‪Environment::getPublicPath() . '/fileadmin/aDirectory/bar.txt', 'myData');
153  $subject->addFileMount('/aDirectory/', ['read_only' => false]);
154  $file = GeneralUtility::makeInstance(ResourceFactory::class)->getFileObjectFromCombinedIdentifier('1:/aDirectory/bar.txt');
155  $rootProcessingFolder = $subject->getProcessingFolder();
156  $processingFolder = $subject->getProcessingFolder($file);
157  self::assertInstanceOf(Folder::class, $processingFolder);
158  self::assertNotEquals($rootProcessingFolder, $processingFolder);
159  for ($i = ‪ResourceStorage::PROCESSING_FOLDER_LEVELS; $i>0; $i--) {
160  $processingFolder = $processingFolder->getParentFolder();
161  }
162  self::assertEquals($rootProcessingFolder, $processingFolder);
163  }
164 
165  public static function ‪isWithinFileMountBoundariesDataProvider(): array
166  {
167  return [
168  'Access to file in ro file mount denied for write request' => [
169  '$targetDirectory' => 'fooBaz',
170  '$fileMountFolder' => 'fooBaz',
171  '$isFileMountReadOnly' => true,
172  '$checkWriteAccess' => true,
173  '$expectedResult' => false,
174  ],
175  'Access to file in ro file mount allowed for read request' => [
176  '$targetDirectory' => 'fooBaz',
177  '$fileMountFolder' => 'fooBaz',
178  '$isFileMountReadOnly' => true,
179  '$checkWriteAccess' => false,
180  '$expectedResult' => true,
181  ],
182  'Access to file in rw file mount allowed for write request' => [
183  '$targetDirectory' => 'fooBaz',
184  '$fileMountFolder' => 'fooBaz',
185  '$isFileMountReadOnly' => false,
186  '$checkWriteAccess' => true,
187  '$expectedResult' => true,
188  ],
189  'Access to file in rw file mount allowed for read request' => [
190  '$targetDirectory' => 'fooBaz',
191  '$fileMountFolder' => 'fooBaz',
192  '$isFileMountReadOnly' => false,
193  '$checkWriteAccess' => false,
194  '$expectedResult' => true,
195  ],
196  'Access to file not in file mount denied for write request' => [
197  '$targetDirectory' => 'fooBaz',
198  '$fileMountFolder' => 'barBaz',
199  '$isFileMountReadOnly' => false,
200  '$checkWriteAccess' => true,
201  '$expectedResult' => false,
202  ],
203  'Access to file not in file mount denied for read request' => [
204  '$targetDirectory' => 'fooBaz',
205  '$fileMountFolder' => 'barBaz',
206  '$isFileMountReadOnly' => false,
207  '$checkWriteAccess' => false,
208  '$expectedResult' => false,
209  ],
210  ];
211  }
212 
217  public function ‪isWithinFileMountBoundariesRespectsReadOnlyFileMounts(string $targetDirectory, string $fileMountFolder, bool $isFileMountReadOnly, bool $checkWriteAccess, bool $expectedResult): void
218  {
219  $this->importCSVDataSet(__DIR__ . '/../Fixtures/sys_file_storage.csv');
220  $fileName = 'bar.txt';
221  $this->importCSVDataSet(__DIR__ . '/../Fixtures/be_users.csv');
222  $this->setUpBackendUser(1);
223  mkdir(‪Environment::getPublicPath() . '/fileadmin/_processed_');
224  mkdir(‪Environment::getPublicPath() . '/fileadmin/' . $targetDirectory);
225  if ($fileMountFolder !== $targetDirectory) {
226  mkdir(‪Environment::getPublicPath() . '/fileadmin/' . $fileMountFolder);
227  }
228  file_put_contents(‪Environment::getPublicPath() . '/fileadmin/' . $targetDirectory . '/' . $fileName, 'myData');
229  $file = GeneralUtility::makeInstance(ResourceFactory::class)->getFileObjectFromCombinedIdentifier('1:/' . $targetDirectory . '/' . $fileName);
230  $subject = GeneralUtility::makeInstance(StorageRepository::class)->findByUid(1);
231  $subject->setEvaluatePermissions(true);
232  // read_only = true -> no write access for user, so checking for second argument true should assert false
233  $subject->addFileMount('/' . $fileMountFolder . '/', ['read_only' => $isFileMountReadOnly]);
234  self::assertSame($expectedResult, $subject->isWithinFileMountBoundaries($file, $checkWriteAccess));
235  }
236 
240  public function ‪getProcessingRootFolderTest(): void
241  {
242  $this->importCSVDataSet(__DIR__ . '/../Fixtures/sys_file_storage.csv');
243  $this->importCSVDataSet(__DIR__ . '/../Fixtures/be_users.csv');
244  $this->setUpBackendUser(1);
245  $subject = GeneralUtility::makeInstance(StorageRepository::class)->findByUid(1);
246  $processingFolder = $subject->getProcessingFolder();
247  self::assertInstanceOf(Folder::class, $processingFolder);
248  }
249 
254  {
255  $folderIdentifier = ‪StringUtility::getUniqueId();
256  $this->importCSVDataSet(__DIR__ . '/../Fixtures/sys_file_storage.csv');
257  $this->importCSVDataSet(__DIR__ . '/../Fixtures/be_users.csv');
258  $this->setUpBackendUser(1);
259  $subject = GeneralUtility::makeInstance(StorageRepository::class)->findByUid(1);
260  $folder = new ‪Folder($subject, '/foo/' . $folderIdentifier . '/', $folderIdentifier);
261  $role = $subject->getRole($folder);
262  self::assertSame(‪FolderInterface::ROLE_DEFAULT, $role);
263  }
264 
269  {
270  $this->importCSVDataSet(__DIR__ . '/../Fixtures/sys_file_storage.csv');
271  $this->importCSVDataSet(__DIR__ . '/../Fixtures/be_users.csv');
272  $this->setUpBackendUser(1);
273  $subject = GeneralUtility::makeInstance(StorageRepository::class)->findByUid(1);
274  mkdir(‪Environment::getPublicPath() . '/fileadmin/foo');
275  file_put_contents(‪Environment::getPublicPath() . '/fileadmin/foo/bar.txt', 'myData');
276  $file = GeneralUtility::makeInstance(ResourceFactory::class)->getFileObjectFromCombinedIdentifier('1:/foo/bar.txt');
277  $this->expectException(\InvalidArgumentException::class);
278  $this->expectExceptionCode(1325842622);
279  $subject->replaceFile($file, ‪Environment::getPublicPath() . '/' . ‪StringUtility::getUniqueId());
280  }
281 
286  {
287  $this->importCSVDataSet(__DIR__ . '/../Fixtures/sys_file_storage.csv');
288  $this->importCSVDataSet(__DIR__ . '/../Fixtures/be_users.csv');
289  $this->setUpBackendUser(1);
290  $subject = GeneralUtility::makeInstance(StorageRepository::class)->findByUid(1);
291  $this->expectException(\InvalidArgumentException::class);
292  $this->expectExceptionCode(1325689164);
293  $subject->createFolder('newFolder', new ‪Folder($subject, '/foo/', 'foo'));
294  }
295 
300  {
301  $this->importCSVDataSet(__DIR__ . '/../Fixtures/sys_file_storage.csv');
302  $this->importCSVDataSet(__DIR__ . '/../Fixtures/be_users.csv');
303  $this->setUpBackendUser(1);
304  $subject = GeneralUtility::makeInstance(StorageRepository::class)->findByUid(1);
305  mkdir(‪Environment::getPublicPath() . '/fileadmin/foo');
306  mkdir(‪Environment::getPublicPath() . '/fileadmin/_recycler_');
307  file_put_contents(‪Environment::getPublicPath() . '/fileadmin/foo/bar.txt', 'myData');
308  $file = GeneralUtility::makeInstance(ResourceFactory::class)->getFileObjectFromCombinedIdentifier('1:/foo/bar.txt');
309  $subject->deleteFile($file);
310  self::assertFileExists(‪Environment::getPublicPath() . '/fileadmin/_recycler_/bar.txt');
311  self::assertFileDoesNotExist(‪Environment::getPublicPath() . '/fileadmin/foo/bar.txt');
312  }
313 
318  {
319  $this->importCSVDataSet(__DIR__ . '/../Fixtures/sys_file_storage.csv');
320  $this->importCSVDataSet(__DIR__ . '/../Fixtures/be_users.csv');
321  $this->setUpBackendUser(1);
322  $subject = GeneralUtility::makeInstance(StorageRepository::class)->findByUid(1);
323  mkdir(‪Environment::getPublicPath() . '/fileadmin/foo');
324  file_put_contents(‪Environment::getPublicPath() . '/fileadmin/foo/bar.txt', 'myData');
325  $file = GeneralUtility::makeInstance(ResourceFactory::class)->getFileObjectFromCombinedIdentifier('1:/foo/bar.txt');
326  $subject->deleteFile($file);
327  self::assertFileDoesNotExist(‪Environment::getPublicPath() . '/fileadmin/foo/bar.txt');
328  }
329 
330  public static function ‪searchFilesFindsFilesInFolderDataProvider(): array
331  {
332  return [
333  'Finds foo recursive by name' => [
334  'foo',
335  '/bar/',
336  true,
337  [],
338  [
339  '/bar/bla/foo.txt',
340  ],
341  ],
342  'Finds foo not recursive by name' => [
343  'foo',
344  '/bar/bla/',
345  false,
346  [],
347  [
348  '/bar/bla/foo.txt',
349  ],
350  ],
351  'Finds nothing when not recursive for top level folder' => [
352  'foo',
353  '/bar/',
354  false,
355  [],
356  [],
357  ],
358  'Finds foo by description' => [
359  'fodescrip',
360  '/bar/',
361  true,
362  [],
363  [
364  '/bar/bla/foo.txt',
365  ],
366  ],
367  'Finds foo by translated description' => [
368  'fotranslated',
369  '/bar/',
370  true,
371  [],
372  [
373  '/bar/bla/foo.txt',
374  ],
375  ],
376  'Finds blupp by name' => [
377  'blupp',
378  '/bar/',
379  false,
380  [],
381  [
382  '/bar/blupp.txt',
383  ],
384  ],
385  'Finds only blupp by title for non recursive' => [
386  'title',
387  '/bar/',
388  false,
389  [],
390  [
391  '/bar/blupp.txt',
392  ],
393  ],
394  'Finds foo and blupp by title for recursive' => [
395  'title',
396  '/bar/',
397  true,
398  [],
399  [
400  '/bar/blupp.txt',
401  '/bar/bla/foo.txt',
402  ],
403  ],
404  'Finds foo, baz and blupp with no folder' => [
405  'title',
406  null,
407  true,
408  [],
409  [
410  '/baz/bla/baz.txt',
411  '/bar/blupp.txt',
412  '/bar/bla/foo.txt',
413  ],
414  ],
415  'Finds nothing for not existing' => [
416  'baz',
417  '/bar/',
418  true,
419  [],
420  [],
421  ],
422  'Finds nothing in root, when not recursive' => [
423  'title',
424  '/',
425  false,
426  [],
427  [],
428  ],
429  'Finds nothing, when not recursive and no folder given' => [
430  'title',
431  null,
432  false,
433  [],
434  [],
435  ],
436  'Filter is applied to result' => [
437  'title',
438  null,
439  true,
440  [
441  static function ($itemName) {
442  return str_contains($itemName, 'blupp') ? true : -1;
443  },
444  ],
445  [
446  '/bar/blupp.txt',
447  ],
448  ],
449  ];
450  }
451 
457  public function ‪searchFilesFindsFilesInFolder(string $searchTerm, ?string $searchFolder, bool $recursive, array $filters, array $expectedIdentifiers): void
458  {
459  $this->importCSVDataSet(__DIR__ . '/../Fixtures/sys_file_storage.csv');
460  $this->importCSVDataSet(__DIR__ . '/Fixtures/FileSearch.csv');
461  $this->importCSVDataSet(__DIR__ . '/../Fixtures/be_users.csv');
462  $this->setUpBackendUser(1);
463  $subject = GeneralUtility::makeInstance(StorageRepository::class)->findByUid(1);
464  $subject->setFileAndFolderNameFilters($filters);
465  mkdir(‪Environment::getPublicPath() . '/fileadmin/bar');
466  mkdir(‪Environment::getPublicPath() . '/fileadmin/bar/bla');
467  mkdir(‪Environment::getPublicPath() . '/fileadmin/baz');
468  mkdir(‪Environment::getPublicPath() . '/fileadmin/baz/bla');
469  file_put_contents(‪Environment::getPublicPath() . '/fileadmin/bar/bla/foo.txt', 'myData');
470  file_put_contents(‪Environment::getPublicPath() . '/fileadmin/baz/bla/baz.txt', 'myData');
471  file_put_contents(‪Environment::getPublicPath() . '/fileadmin/bar/blupp.txt', 'myData');
472  $folder = $searchFolder ? GeneralUtility::makeInstance(ResourceFactory::class)->getFolderObjectFromCombinedIdentifier('1:' . $searchFolder) : null;
473  $search = ‪FileSearchDemand::createForSearchTerm($searchTerm);
474  if ($recursive) {
475  $search = $search->withRecursive();
476  }
477  $result = $subject->searchFiles($search, $folder);
478  $expectedFiles = array_map([$subject, 'getFile'], $expectedIdentifiers);
479  self::assertSame($expectedFiles, iterator_to_array($result));
480  // Check if search also works for non-hierarchical storages/drivers
481  // This is a hack, as capabilities is not settable from the outside
482  $objectReflection = new \ReflectionObject($subject);
483  $property = $objectReflection->getProperty('capabilities');
484  $property->setAccessible(true);
485  $property->setValue($subject, $subject->getCapabilities() & 7);
486  $result = $subject->searchFiles($search, $folder);
487  $expectedFiles = array_map([$subject, 'getFile'], $expectedIdentifiers);
488  self::assertSame($expectedFiles, iterator_to_array($result));
489  }
490 
495  {
497  $this->importCSVDataSet(__DIR__ . '/../Fixtures/sys_file_storage.csv');
498  $this->importCSVDataSet(__DIR__ . '/../Fixtures/be_users.csv');
499  $this->setUpBackendUser(1);
500  $subject = GeneralUtility::makeInstance(StorageRepository::class)->findByUid(1);
501  mkdir(‪Environment::getPublicPath() . '/fileadmin/foo');
502  $folderToCopy = GeneralUtility::makeInstance(ResourceFactory::class)->getFolderObjectFromCombinedIdentifier('1:/foo');
503  $targetParentFolder = GeneralUtility::makeInstance(ResourceFactory::class)->getFolderObjectFromCombinedIdentifier('1:/');
504  $this->expectException(InvalidTargetFolderException::class);
505  $this->expectExceptionCode(1422723059);
506  $subject->copyFolder($folderToCopy, $targetParentFolder, null, $conflictMode);
507  }
508 
513  {
515  $this->importCSVDataSet(__DIR__ . '/../Fixtures/sys_file_storage.csv');
516  $this->importCSVDataSet(__DIR__ . '/../Fixtures/be_users.csv');
517  $this->setUpBackendUser(1);
518  $subject = GeneralUtility::makeInstance(StorageRepository::class)->findByUid(1);
519  mkdir(‪Environment::getPublicPath() . '/fileadmin/foo');
520  $folderToCopy = GeneralUtility::makeInstance(ResourceFactory::class)->getFolderObjectFromCombinedIdentifier('1:/foo');
521  $targetParentFolder = GeneralUtility::makeInstance(ResourceFactory::class)->getFolderObjectFromCombinedIdentifier('1:/');
522  $subject->copyFolder($folderToCopy, $targetParentFolder, null, $conflictMode);
523  $newFolder = GeneralUtility::makeInstance(ResourceFactory::class)->getFolderObjectFromCombinedIdentifier('1:/foo_01');
524  self::assertInstanceOf(Folder::class, $newFolder);
525  }
526 
531  {
533  $this->importCSVDataSet(__DIR__ . '/../Fixtures/sys_file_storage.csv');
534  $this->importCSVDataSet(__DIR__ . '/../Fixtures/be_users.csv');
535  $this->setUpBackendUser(1);
536  mkdir(‪Environment::getPublicPath() . '/fileadmin/foo');
537  file_put_contents(‪Environment::getPublicPath() . '/fileadmin/foo/bar.txt', 'Temp file 1');
538  file_put_contents(‪Environment::getPublicPath() . '/fileadmin/bar.txt', 'Temp file 2');
539  $subject = GeneralUtility::makeInstance(StorageRepository::class)->findByUid(1);
540  $fileToCopy = GeneralUtility::makeInstance(ResourceFactory::class)->getFileObjectFromCombinedIdentifier('1:/foo/bar.txt');
541  $targetParentFolder = GeneralUtility::makeInstance(ResourceFactory::class)->getFolderObjectFromCombinedIdentifier('1:/');
542  $this->expectException(ExistingTargetFileNameException::class);
543  $this->expectExceptionCode(1320291064);
544  $subject->copyFile($fileToCopy, $targetParentFolder, null, $conflictMode);
545  }
546 
551  {
553  $this->importCSVDataSet(__DIR__ . '/../Fixtures/sys_file_storage.csv');
554  $this->importCSVDataSet(__DIR__ . '/../Fixtures/be_users.csv');
555  $this->setUpBackendUser(1);
556  mkdir(‪Environment::getPublicPath() . '/fileadmin/foo');
557  file_put_contents(‪Environment::getPublicPath() . '/fileadmin/foo/bar.txt', 'Temp file 1');
558  file_put_contents(‪Environment::getPublicPath() . '/fileadmin/bar.txt', 'Temp file 2');
559  $subject = GeneralUtility::makeInstance(StorageRepository::class)->findByUid(1);
560  $fileToCopy = GeneralUtility::makeInstance(ResourceFactory::class)->getFileObjectFromCombinedIdentifier('1:/foo/bar.txt');
561  $targetParentFolder = GeneralUtility::makeInstance(ResourceFactory::class)->getFolderObjectFromCombinedIdentifier('1:/');
562  $subject->copyFile($fileToCopy, $targetParentFolder, null, $conflictMode);
563  $newFile = GeneralUtility::makeInstance(ResourceFactory::class)->getFileObjectFromCombinedIdentifier('1:/bar_01.txt');
564  self::assertInstanceOf(File::class, $newFile);
565  }
566 }
‪TYPO3\CMS\Core\Resource\DuplicationBehavior
Definition: DuplicationBehavior.php:24
‪TYPO3\CMS\Core\Tests\Functional\Resource\StorageRepositoryTest
Definition: StorageRepositoryTest.php:36
‪TYPO3\CMS\Core\Resource\DuplicationBehavior\CANCEL
‪const CANCEL
Definition: DuplicationBehavior.php:46
‪TYPO3\CMS\Core\Resource\ResourceStorage\PROCESSING_FOLDER_LEVELS
‪const PROCESSING_FOLDER_LEVELS
Definition: ResourceStorage.php:212
‪TYPO3\CMS\Core\Tests\Functional\Resource
Definition: DefaultUploadFolderResolverTest.php:18
‪TYPO3\CMS\Core\Tests\Functional\Resource\StorageRepositoryTest\bestStorageIsResolved
‪bestStorageIsResolved(string $sourceIdentifier, string $expectedCombinedIdentifier)
Definition: StorageRepositoryTest.php:101
‪TYPO3\CMS\Core\Resource\FolderInterface\ROLE_DEFAULT
‪const ROLE_DEFAULT
Definition: FolderInterface.php:26
‪TYPO3\CMS\Core\Core\Environment\getPublicPath
‪static getPublicPath()
Definition: Environment.php:187
‪TYPO3\CMS\Core\Resource\Exception\ExistingTargetFileNameException
Definition: ExistingTargetFileNameException.php:24
‪TYPO3\CMS\Core\Tests\Functional\Resource\StorageRepositoryTest\tearDown
‪tearDown()
Definition: StorageRepositoryTest.php:37
‪TYPO3\CMS\Core\Tests\Functional\Resource\StorageRepositoryTest\replaceFileFailsIfLocalFileDoesNotExist
‪replaceFileFailsIfLocalFileDoesNotExist()
Definition: StorageRepositoryTest.php:268
‪TYPO3\CMS\Core\Resource\Exception\InvalidTargetFolderException
Definition: InvalidTargetFolderException.php:24
‪TYPO3\CMS\Core\Tests\Functional\Resource\StorageRepositoryTest\isWithinFileMountBoundariesRespectsReadOnlyFileMounts
‪isWithinFileMountBoundariesRespectsReadOnlyFileMounts(string $targetDirectory, string $fileMountFolder, bool $isFileMountReadOnly, bool $checkWriteAccess, bool $expectedResult)
Definition: StorageRepositoryTest.php:217
‪TYPO3\CMS\Core\Tests\Functional\Resource\StorageRepositoryTest\getProcessingRootFolderTest
‪getProcessingRootFolderTest()
Definition: StorageRepositoryTest.php:240
‪TYPO3\CMS\Core\Type\Enumeration\cast
‪static static cast($value)
Definition: Enumeration.php:186
‪TYPO3\CMS\Core\Tests\Functional\Resource\StorageRepositoryTest\createFolderThrowsExceptionIfParentFolderDoesNotExist
‪createFolderThrowsExceptionIfParentFolderDoesNotExist()
Definition: StorageRepositoryTest.php:285
‪TYPO3\CMS\Core\Tests\Functional\Resource\StorageRepositoryTest\searchFilesFindsFilesInFolderDataProvider
‪static searchFilesFindsFilesInFolderDataProvider()
Definition: StorageRepositoryTest.php:330
‪TYPO3\CMS\Core\Tests\Functional\Resource\StorageRepositoryTest\getNestedProcessingFolderTest
‪getNestedProcessingFolderTest()
Definition: StorageRepositoryTest.php:142
‪TYPO3\CMS\Core\Tests\Functional\Resource\StorageRepositoryTest\copyFileGeneratesNewFileNameWhenFileAlreadyExistsInTargetFolderAndConflictModeIsRename
‪copyFileGeneratesNewFileNameWhenFileAlreadyExistsInTargetFolderAndConflictModeIsRename()
Definition: StorageRepositoryTest.php:550
‪TYPO3\CMS\Core\Tests\Functional\Resource\StorageRepositoryTest\searchFilesFindsFilesInFolder
‪searchFilesFindsFilesInFolder(string $searchTerm, ?string $searchFolder, bool $recursive, array $filters, array $expectedIdentifiers)
Definition: StorageRepositoryTest.php:457
‪TYPO3\CMS\Core\Resource\Search\FileSearchDemand
Definition: FileSearchDemand.php:26
‪TYPO3\CMS\Core\Resource\Folder
Definition: Folder.php:37
‪TYPO3\CMS\Core\Resource\ResourceFactory
Definition: ResourceFactory.php:41
‪TYPO3\CMS\Core\Tests\Functional\Resource\StorageRepositoryTest\copyFolderGeneratesNewFolderNameWhenFolderAlreadyExistsInTargetFolderAndConflictModeIsRename
‪copyFolderGeneratesNewFolderNameWhenFolderAlreadyExistsInTargetFolderAndConflictModeIsRename()
Definition: StorageRepositoryTest.php:512
‪TYPO3\CMS\Core\Resource\StorageRepository
Definition: StorageRepository.php:38
‪TYPO3\CMS\Core\Resource\File
Definition: File.php:24
‪TYPO3\CMS\Core\Resource\DuplicationBehavior\RENAME
‪const RENAME
Definition: DuplicationBehavior.php:32
‪TYPO3\CMS\Core\Tests\Functional\Resource\StorageRepositoryTest\copyFileThrowsErrorWhenFileWithSameNameAlreadyExistsInTargetFolderAndConflictModeIsCancel
‪copyFileThrowsErrorWhenFileWithSameNameAlreadyExistsInTargetFolderAndConflictModeIsCancel()
Definition: StorageRepositoryTest.php:530
‪TYPO3\CMS\Core\Tests\Functional\Resource\StorageRepositoryTest\bestStorageIsResolvedDataProvider
‪static bestStorageIsResolvedDataProvider()
Definition: StorageRepositoryTest.php:45
‪TYPO3\CMS\Core\Tests\Functional\Resource\StorageRepositoryTest\copyFolderThrowsErrorWhenFolderAlreadyExistsInTargetFolderAndConflictModeIsCancel
‪copyFolderThrowsErrorWhenFolderAlreadyExistsInTargetFolderAndConflictModeIsCancel()
Definition: StorageRepositoryTest.php:494
‪TYPO3\CMS\Core\Resource\ResourceStorage
Definition: ResourceStorage.php:127
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:41
‪TYPO3\CMS\Core\Resource\FolderInterface
Definition: FolderInterface.php:22
‪TYPO3\CMS\Core\Utility\GeneralUtility\rmdir
‪static bool rmdir($path, $removeNonEmpty=false)
Definition: GeneralUtility.php:1806
‪TYPO3\CMS\Core\Tests\Functional\Resource\StorageRepositoryTest\deleteFileUnlinksFileIfNoRecyclerFolderAvailable
‪deleteFileUnlinksFileIfNoRecyclerFolderAvailable()
Definition: StorageRepositoryTest.php:317
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:51
‪TYPO3\CMS\Core\Resource\Search\FileSearchDemand\createForSearchTerm
‪static createForSearchTerm(string $searchTerm)
Definition: FileSearchDemand.php:70
‪TYPO3\CMS\Core\Utility\StringUtility
Definition: StringUtility.php:24
‪TYPO3\CMS\Core\Tests\Functional\Resource\StorageRepositoryTest\getRoleReturnsDefaultForRegularFolders
‪getRoleReturnsDefaultForRegularFolders()
Definition: StorageRepositoryTest.php:253
‪TYPO3\CMS\Core\Tests\Functional\Resource\StorageRepositoryTest\deleteFileMovesFileToRecyclerFolderIfAvailable
‪deleteFileMovesFileToRecyclerFolderIfAvailable()
Definition: StorageRepositoryTest.php:299
‪TYPO3\CMS\Core\Utility\StringUtility\getUniqueId
‪static getUniqueId(string $prefix='')
Definition: StringUtility.php:29
‪TYPO3\CMS\Core\Tests\Functional\Resource\StorageRepositoryTest\isWithinFileMountBoundariesDataProvider
‪static isWithinFileMountBoundariesDataProvider()
Definition: StorageRepositoryTest.php:165