18 use \org\bovigo\vfs\vfsStream;
19 use \org\bovigo\vfs\vfsStreamWrapper;
62 foreach ($this->testDirs as $dir) {
92 $fixture = $this->createDriverFixture(array(
107 protected function createDriverFixture($driverConfiguration = array(), $mockedDriverMethods = array()) {
109 if (!isset($driverConfiguration[
'basePath'])) {
114 $mockedDriverMethods[] =
'isPathValid';
115 $driver = $this->
getAccessibleMock(
'TYPO3\\CMS\\Core\\Resource\\Driver\\LocalDriver', $mockedDriverMethods, array($driverConfiguration));
117 ->method(
'isPathValid')
119 $this->returnValue(TRUE)
123 $driver->processConfiguration();
132 $fixture = $this->createDriverFixture();
135 $relativeDriverConfiguration = array(
136 'pathType' =>
'relative',
137 'basePath' =>
'/typo3temp/',
139 $basePath = $fixture->_call(
'calculateBasePath', $relativeDriverConfiguration);
141 $this->assertNotContains(
'//', $basePath);
148 $fixture = $this->createDriverFixture();
151 $relativeDriverConfiguration = array(
152 'basePath' => PATH_site .
'typo3temp/../typo3temp/',
154 $basePath = $fixture->_call(
'calculateBasePath', $relativeDriverConfiguration);
156 $this->assertNotContains(
'/../', $basePath);
162 public function createFolderRecursiveSanitizesFilename() {
164 $driver = $this->createDriverFixture(array(), array(
'sanitizeFilename'));
165 $driver->expects($this->exactly(2))
166 ->method(
'sanitizeFileName')
168 $this->returnValue(
'sanitized')
170 $driver->createFolder(
'newFolder/andSubfolder',
'/', TRUE);
171 $this->assertFileExists($this->
getUrlInMount(
'/sanitized/sanitized/'));
177 public function determineBaseUrlUrlEncodesUriParts() {
179 $driver = $this->
getAccessibleMock(
'TYPO3\\CMS\\Core\\Resource\\Driver\\LocalDriver', array(
'hasCapability'), array(),
'', FALSE);
180 $driver->expects($this->once())
181 ->method(
'hasCapability')
184 $this->returnValue(TRUE)
186 $driver->_set(
'absoluteBasePath', PATH_site .
'un encö/ded %path/');
187 $driver->_call(
'determineBaseUrl');
188 $baseUri =
$driver->_get(
'baseUri');
189 $this->assertEquals(rawurlencode(
'un encö') .
'/' . rawurlencode(
'ded %path') .
'/', $baseUri);
196 $fixture = $this->createDriverFixture();
197 $folderIdentifier = $fixture->getDefaultFolder();
198 $this->assertEquals(
'/user_upload/', $folderIdentifier);
205 $fixture = $this->createDriverFixture();
206 $this->assertFileExists($this->
getUrlInMount($fixture->getDefaultFolder()));
215 'someSubdir' => array()
218 $fixture = $this->createDriverFixture();
219 $folder = $fixture->getFolderInFolder(
'someSubdir',
'/someDir/');
220 $this->assertEquals(
'/someDir/someSubdir/', $folder);
227 $this->
addToMount(array(
'some' => array(
'folder' => array())));
228 $fixture = $this->createDriverFixture();
229 $fixture->createFolder(
'path',
'/some/folder/');
230 $this->assertFileExists($this->
getUrlInMount(
'/some/folder/'));
231 $this->assertFileExists($this->
getUrlInMount(
'/some/folder/path'));
238 $this->
addToMount(array(
'some' => array(
'folder' => array())));
239 $fixture = $this->createDriverFixture();
240 $createdFolder = $fixture->createFolder(
'path',
'/some/folder/');
241 $this->assertEquals(
'/some/folder/path/', $createdFolder);
246 'folder name with NULL character' => array(
247 'some' . chr(0) .
'Folder',
250 'folder name with directory part' => array(
262 $this->
addToMount(array(
'some' => array(
'folder' => array())));
263 $fixture = $this->createDriverFixture();
264 $fixture->createFolder($newFolderName,
'/some/folder/');
265 $this->assertFileExists($this->
getUrlInMount(
'/some/folder/' . $expectedFolderName));
272 $fixture = $this->createDriverFixture();
273 $this->assertEquals(
'/', substr($fixture->_call(
'getAbsoluteBasePath'), -1));
280 $fixture = $this->createDriverFixture();
281 $this->assertNotEquals(
'/', substr($fixture->_call(
'getAbsoluteBasePath'), -2, 1));
289 'someFolder' => array(
290 'file1.ext' =>
'asdfg' 293 $fixture = $this->createDriverFixture();
294 $path = $fixture->_call(
'getAbsolutePath',
'/someFolder/file1.ext');
295 $this->assertTrue(file_exists($path));
296 $this->assertEquals($this->
getUrlInMount(
'/someFolder/file1.ext'), $path);
303 $this->
addToMount(array(
'targetFolder' => array()));
305 'sourceFolder' => array(
309 $fixture = $this->createDriverFixture(
311 array(
'getMimeTypeOfFile')
313 $this->assertTrue(file_exists($this->
getUrl(
'sourceFolder/file')));
314 $fixture->addFile($this->
getUrl(
'sourceFolder/file'),
'/targetFolder/',
'file');
315 $this->assertTrue(file_exists($this->
getUrlInMount(
'/targetFolder/file')));
322 $this->
addToMount(array(
'targetFolder' => array()));
324 'sourceFolder' => array(
328 $fixture = $this->createDriverFixture(
330 array(
'getMimeTypeOfFile')
332 $this->assertTrue(file_exists($this->
getUrl(
'sourceFolder/file')));
333 $fixture->addFile($this->
getUrl(
'sourceFolder/file'),
'/targetFolder/',
'targetFile');
334 $this->assertTrue(file_exists($this->
getUrlInMount(
'/targetFolder/targetFile')));
341 $this->setExpectedException(
'InvalidArgumentException',
'', 1314778269);
343 'targetFolder' => array(
347 $fixture = $this->createDriverFixture();
348 $fixture->addFile($this->
getUrlInMount(
'/targetFolder/file'),
'/targetFolder/',
'file');
355 $this->
addToMount(array(
'targetFolder' => array()));
357 'sourceFolder' => array(
361 $fixture = $this->createDriverFixture(
363 array(
'getMimeTypeOfFile')
365 $this->assertTrue(file_exists($this->
getUrl(
'sourceFolder/file')));
366 $fileIdentifier = $fixture->addFile($this->
getUrl(
'sourceFolder/file'),
'/targetFolder/',
'file');
367 $this->assertEquals(
'file', basename($fileIdentifier));
368 $this->assertEquals(
'/targetFolder/file', $fileIdentifier);
379 $fixture = $this->createDriverFixture();
381 $this->assertTrue($fixture->fileExists(
'/file'));
382 $this->assertTrue($fixture->folderExists(
'/folder/'));
383 $this->assertFalse($fixture->fileExists(
'/nonexistingFile'));
384 $this->assertFalse($fixture->folderExists(
'/nonexistingFolder/'));
392 'subfolder' => array(
397 $fixture = $this->createDriverFixture();
398 $this->assertTrue($fixture->fileExistsInFolder(
'file',
'/subfolder/'));
399 $this->assertTrue($fixture->folderExistsInFolder(
'folder',
'/subfolder/'));
400 $this->assertFalse($fixture->fileExistsInFolder(
'nonexistingFile',
'/subfolder/'));
401 $this->assertFalse($fixture->folderExistsInFolder(
'nonexistingFolder',
'/subfolder/'));
408 $baseUri =
'http://example.org/foobar/' . $this->
getUniqueId();
410 'file.ext' =>
'asdf',
411 'subfolder' => array(
412 'file2.ext' =>
'asdf' 415 $fixture = $this->createDriverFixture(array(
416 'baseUri' => $baseUri
418 $this->assertEquals($baseUri .
'/file.ext', $fixture->getPublicUrl(
'/file.ext'));
419 $this->assertEquals($baseUri .
'/subfolder/file2.ext', $fixture->getPublicUrl(
'/subfolder/file2.ext'));
429 array(
'/single file with some special chars äüö!.txt'),
430 array(
'/on subfolder/with special chars äüö!.ext'),
431 array(
'/who names a file like !"§$%&()=?*+~"#\'´`<>-.ext'),
432 array(
'no leading slash !"§$%&()=?*+~#\'"´`"<>-.txt')
441 $baseUri =
'http://example.org/foobar/' . $this->
getUniqueId();
442 $fixture = $this->createDriverFixture(array(
443 'baseUri' => $baseUri
445 $publicUrl = $fixture->getPublicUrl($fileIdentifier);
453 $fileContents =
'asdf';
455 'file.ext' => $fileContents
457 $fixture = $this->createDriverFixture();
458 $this->assertEquals($fileContents, $fixture->getFileContents(
'/file.ext'),
'File contents could not be read');
459 $newFileContents =
'asdfgh';
460 $fixture->setFileContents(
'/file.ext', $newFileContents);
461 $this->assertEquals($newFileContents, $fixture->getFileContents(
'/file.ext'),
'New file contents could not be read.');
468 $fileContents =
'asdf';
470 'file.ext' => $fileContents
472 $fixture = $this->createDriverFixture();
473 $newFileContents =
'asdfgh';
474 $bytesWritten = $fixture->setFileContents(
'/file.ext', $newFileContents);
475 $this->assertEquals(strlen($newFileContents), $bytesWritten);
483 if (version_compare(PHP_VERSION,
'5.4.0',
'<')) {
484 $this->markTestSkipped(
'touch() does not work with vfsStream in PHP 5.3 and below.');
486 $fixture = $this->createDriverFixture();
487 $fixture->createFile(
'testfile.txt',
'/');
488 $this->assertTrue($fixture->fileExists(
'/testfile.txt'));
496 if (version_compare(PHP_VERSION,
'5.4.0',
'<')) {
497 $this->markTestSkipped(
'touch() does not work with vfsStream in PHP 5.3 and below.');
499 $fixture = $this->createDriverFixture();
500 $fixture->createFile(
'testfile.txt',
'/');
501 $this->assertTrue($fixture->fileExists(
'/testfile.txt'));
502 $fileData = $fixture->getFileContents(
'/testfile.txt');
503 $this->assertEquals(0, strlen($fileData));
509 public function createFileFixesPermissionsOnCreatedFile() {
510 if (TYPO3_OS ==
'WIN') {
511 $this->markTestSkipped(
'createdFilesHaveCorrectRights() tests not available on Windows');
515 $testpattern =
'0646';
516 $GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'fileCreateMask'] = $testpattern;
526 $fixture->createFile(
'testfile.txt',
'/someDir');
527 $this->assertEquals($testpattern, decoct(fileperms(
$basedir .
'/someDir/testfile.txt') & 0777));
539 'someFile' =>
'asdfg' 541 'someFileAtRootLevel' =>
'foobar' 543 $fixture = $this->createDriverFixture(
545 array(
'getMimeTypeOfFile')
547 $subdirFileInfo = $fixture->getFileInfoByIdentifier(
'/someDir/someFile');
548 $this->assertEquals(
'/someDir/someFile', $subdirFileInfo[
'identifier']);
549 $rootFileInfo = $fixture->getFileInfoByIdentifier(
'/someFileAtRootLevel');
550 $this->assertEquals(
'/someFileAtRootLevel', $rootFileInfo[
'identifier']);
557 $this->setExpectedException(
'InvalidArgumentException',
'', 1314516809);
558 $fixture = $this->createDriverFixture();
559 $fixture->getFileInfoByIdentifier(
'/some/file/at/a/random/path');
566 $fixture = $this->createDriverFixture();
567 $fileList = $fixture->getFilesInFolder(
'/');
568 $this->assertEmpty($fileList);
575 $dirStructure = array(
581 $fixture = $this->createDriverFixture(
584 array(
'getMimeTypeOfFile')
586 $fileList = $fixture->getFilesInFolder(
'/');
587 $this->assertEquals(array(
'/file1',
'/file2'), array_keys($fileList));
594 $dirStructure = array(
598 'file4' =>
'asklfjklasjkl' 605 $fixture = $this->createDriverFixture(
608 array(
'getMimeTypeOfFile')
610 $fileList = $fixture->getFilesInFolder(
'/', 0, 0, TRUE);
611 $this->assertEquals(array(
'/aDir/subdir/file4',
'/aDir/file3',
'/file1',
'/file2'), array_keys($fileList));
618 $this->setExpectedException(
'InvalidArgumentException',
'', 1314349666);
620 $fixture = $this->createDriverFixture();
621 $fixture->getFilesInFolder(
'somedir/');
628 $dirStructure = array(
635 'callbackStaticTestFunction' 639 $fixture = $this->createDriverFixture();
641 $this->setExpectedException(
'InvalidArgumentException',
'$itemName', 1336159604);
642 $fixture->getFilesInFolder(
'/', 0, 0, FALSE, $callback);
654 list($itemName) = func_get_args();
655 if ($itemName ===
'file2') {
656 throw new \InvalidArgumentException(
'$itemName', 1336159604);
664 $dirStructure = array(
669 $fixture = $this->createDriverFixture(
672 array(
'getMimeTypeOfFile')
674 $filterCallbacks = array(
676 'TYPO3\CMS\Core\Tests\Unit\Resource\Driver\Fixtures\LocalDriverFilenameFilter',
680 $fileList = $fixture->getFilesInFolder(
'/', 0, 0, FALSE, $filterCallbacks);
681 $this->assertNotContains(
'/fileA', array_keys($fileList));
688 $dirStructure = array(
694 $fixture = $this->createDriverFixture();
695 $fileList = $fixture->getFoldersInFolder(
'/');
696 $this->assertEquals(array(
'/dir1/',
'/dir2/'), array_keys($fileList));
703 $dirStructure = array(
704 '.someHiddenDir' => array(),
709 $fixture = $this->createDriverFixture();
711 $fileList = $fixture->getFoldersInFolder(
'/');
713 $this->assertEquals(array(
'/.someHiddenDir/',
'/aDir/'), array_keys($fileList));
728 $fixture = $this->createDriverFixture();
729 $fileList = $fixture->getFoldersInFolder(
'/');
730 $this->assertEmpty($fileList);
737 $dirStructure = array(
738 'folderA' => array(),
742 $fixture = $this->createDriverFixture();
743 $filterCallbacks = array(
745 'TYPO3\CMS\Core\Tests\Unit\Resource\Driver\Fixtures\LocalDriverFilenameFilter',
749 $folderList = $fixture->getFoldersInFolder(
'/', 0, 0, $filterCallbacks);
750 $this->assertNotContains(
'folderA', array_keys($folderList));
757 $this->setExpectedException(
'InvalidArgumentException',
'', 1314349666);
758 $fixture = $this->createDriverFixture();
759 vfsStream::create(array($this->basedir => array(
'somefile' =>
'')));
760 $fixture->getFoldersInFolder(
'somedir/');
767 $contents =
'68b329da9893e34099c7d8ad5cb9c940';
768 $expectedMd5Hash =
'8c67dbaf0ba22f2e7fbc26413b86051b';
769 $expectedSha1Hash =
'a60cd808ba7a0bcfa37fa7f3fb5998e1b8dbcd9d';
770 $this->
addToMount(array(
'hashFile' => $contents));
771 $fixture = $this->createDriverFixture();
772 $this->assertEquals($expectedSha1Hash, $fixture->hash(
'/hashFile',
'sha1'));
773 $this->assertEquals($expectedMd5Hash, $fixture->hash(
'/hashFile',
'md5'));
780 $this->setExpectedException(
'InvalidArgumentException',
'', 1304964032);
781 $fixture = $this->createDriverFixture();
790 $fileContents =
'asdfgh';
793 'someFile' => $fileContents
796 $fixture = $this->createDriverFixture(array(), array(
'copyFileToTemporaryPath'));
797 $fixture->expects($this->once())->method(
'copyFileToTemporaryPath');
798 $fixture->getFileForLocalProcessing(
'/someDir/someFile');
805 $fileContents =
'asdfgh';
808 'someFile' => $fileContents
811 $fixture = $this->createDriverFixture();
812 $filePath = $fixture->getFileForLocalProcessing(
'/someDir/someFile', FALSE);
813 $this->assertEquals($filePath, $this->
getUrlInMount(
'someDir/someFile'));
820 $fileContents =
'asdfgh';
823 'someFile' => $fileContents
826 $fixture = $this->createDriverFixture();
828 $this->assertContains(
'/typo3temp/', $filePath);
829 $this->assertEquals($fileContents, file_get_contents($filePath));
835 public function permissionsAreCorrectlyRetrievedForAllowedFile() {
841 $this->assertEquals(array(
'r' => TRUE,
'w' => TRUE), $fixture->getPermissions(
'/someFile'));
847 public function permissionsAreCorrectlyRetrievedForForbiddenFile() {
848 if (function_exists(
'posix_getegid') && posix_getegid() === 0) {
849 $this->markTestSkipped(
'Test skipped if run on linux as root');
850 } elseif (TYPO3_OS ===
'WIN') {
851 $this->markTestSkipped(
'Test skipped if run on Windows system');
855 touch(
$basedir .
'/someForbiddenFile');
856 chmod(
$basedir .
'/someForbiddenFile', 0);
858 $this->assertEquals(array(
'r' => FALSE,
'w' => FALSE), $fixture->getPermissions(
'/someForbiddenFile'));
864 public function permissionsAreCorrectlyRetrievedForAllowedFolder() {
868 chmod(
$basedir .
'/someFolder', 448);
870 $this->assertEquals(array(
'r' => TRUE,
'w' => TRUE), $fixture->getPermissions(
'/someFolder'));
876 public function permissionsAreCorrectlyRetrievedForForbiddenFolder() {
877 if (function_exists(
'posix_getegid') && posix_getegid() === 0) {
878 $this->markTestSkipped(
'Test skipped if run on linux as root');
879 } elseif (TYPO3_OS ===
'WIN') {
880 $this->markTestSkipped(
'Test skipped if run on Windows system');
884 mkdir(
$basedir .
'/someForbiddenFolder');
885 chmod(
$basedir .
'/someForbiddenFolder', 0);
887 $result = $fixture->getPermissions(
'/someForbiddenFolder');
889 chmod(
$basedir .
'/someForbiddenFolder', 0777);
890 $this->assertEquals(array(
'r' => FALSE,
'w' => FALSE),
$result);
901 if (function_exists(
'posix_getgid')) {
903 'current group, readable/writable' => array(
906 array(
'r' => TRUE,
'w' => TRUE)
908 'current group, readable/not writable' => array(
911 array(
'r' => TRUE,
'w' => FALSE)
913 'current group, not readable/not writable' => array(
916 array(
'r' => FALSE,
'w' => FALSE)
920 $data = array_merge_recursive($data, array(
921 'arbitrary group, readable/writable' => array(
922 vfsStream::GROUP_USER_1,
924 array(
'r' => TRUE,
'w' => TRUE)
926 'arbitrary group, readable/not writable' => array(
927 vfsStream::GROUP_USER_1,
929 array(
'r' => TRUE,
'w' => FALSE)
931 'arbitrary group, not readable/not writable' => array(
932 vfsStream::GROUP_USER_1,
934 array(
'r' => FALSE,
'w' => FALSE)
944 public function getFilePermissionsReturnsCorrectPermissionsForFilesNotOwnedByCurrentUser($group, $permissions, $expectedResult) {
945 if (TYPO3_OS ===
'WIN') {
946 $this->markTestSkipped(
'Test skipped if run on Windows system');
949 'testfile' =>
'asdfg' 951 $fixture = $this->createDriverFixture();
953 $fileObject = vfsStreamWrapper::getRoot()->getChild($this->mountDir)->getChild(
'testfile');
955 $fileObject->chown(vfsStream::OWNER_USER_1);
956 $fileObject->chgrp($group);
957 $fileObject->chmod($permissions);
958 $this->assertEquals($expectedResult, $fixture->getPermissions(
'/testfile'));
965 $fixture = $this->createDriverFixture();
966 $this->assertTrue($fixture->isWithin(
'/someFolder/',
'/someFolder/test.jpg'));
967 $this->assertTrue($fixture->isWithin(
'/someFolder/',
'/someFolder/subFolder/test.jpg'));
968 $this->assertFalse($fixture->isWithin(
'/someFolder/',
'/someFolderWithALongName/test.jpg'));
975 $fixture = $this->createDriverFixture();
976 $this->assertTrue($fixture->isWithin(
'/someFolder/',
'/someFolder/test.jpg'));
977 $this->assertTrue($fixture->isWithin(
'/someFolder/',
'/someFolder/subfolder/'));
990 'someFile' => $fileContents,
991 'targetFolder' => array()
993 $fixture = $this->createDriverFixture(
995 array(
'getMimeTypeOfFile')
997 $fixture->copyFileWithinStorage(
'/someFile',
'/targetFolder/',
'someFile');
1007 'targetFolder' => array(),
1008 'someFile' => $fileContents
1010 $fixture = $this->createDriverFixture();
1011 $newIdentifier = $fixture->moveFileWithinStorage(
'/someFile',
'/targetFolder/',
'file');
1012 $this->assertEquals($fileContents, file_get_contents($this->
getUrlInMount(
'/targetFolder/file')));
1013 $this->assertFileNotExists($this->
getUrlInMount(
'/someFile'));
1014 $this->assertEquals(
'/targetFolder/file', $newIdentifier);
1023 'targetFolder' => array(),
1024 'someFile' => $fileContents
1026 $fixture = $this->createDriverFixture(
1029 array(
'getMimeTypeOfFile')
1031 $newIdentifier = $fixture->moveFileWithinStorage(
'/someFile',
'/targetFolder/',
'file');
1032 $fileMetadata = $fixture->getFileInfoByIdentifier($newIdentifier);
1033 $this->assertEquals($newIdentifier, $fileMetadata[
'identifier']);
1038 'file in subfolder' => array(
1040 'targetFolder' => array(
'file' =>
'')
1042 '/targetFolder/file',
1044 '/targetFolder/newFile' 1046 'file in rootfolder' => array(
1063 $fixture = $this->createDriverFixture();
1064 $newIdentifier = $fixture->renameFile($oldFileIdentifier, $newFileName);
1065 $this->assertFalse($fixture->fileExists($oldFileIdentifier));
1066 $this->assertTrue($fixture->fileExists($newIdentifier));
1067 $this->assertEquals($expectedNewIdentifier, $newIdentifier);
1074 $this->setExpectedException(
'TYPO3\\CMS\\Core\\Resource\\Exception\\ExistingTargetFileNameException',
'', 1320291063);
1076 'targetFolder' => array(
'file' =>
'',
'newFile' =>
'')
1078 $fixture = $this->createDriverFixture();
1079 $fixture->renameFile(
'/targetFolder/file',
'newFile');
1089 'folder in root folder' => array(
1091 'someFolder' => array()
1097 'file in subfolder' => array(
1099 'subfolder' => array(
1100 'someFolder' => array()
1103 '/subfolder/someFolder/',
1105 '/subfolder/newFolder/' 1116 $fixture = $this->createDriverFixture();
1117 $mapping = $fixture->renameFolder($oldFolderIdentifier, $newFolderName);
1118 $this->assertFalse($fixture->folderExists($oldFolderIdentifier));
1119 $this->assertTrue($fixture->folderExists($expectedNewIdentifier));
1120 $this->assertEquals($expectedNewIdentifier, $mapping[$oldFolderIdentifier]);
1127 $fileContents =
'asdfg';
1129 'sourceFolder' => array(
1130 'subFolder' => array(
'file' => $fileContents),
1134 $fixture = $this->createDriverFixture();
1135 $mappingInformation = $fixture->renameFolder(
'/sourceFolder/',
'newFolder');
1136 $this->isTrue(is_array($mappingInformation));
1137 $this->assertEquals(
'/newFolder/', $mappingInformation[
'/sourceFolder/']);
1138 $this->assertEquals(
'/newFolder/file2', $mappingInformation[
'/sourceFolder/file2']);
1139 $this->assertEquals(
'/newFolder/subFolder/file', $mappingInformation[
'/sourceFolder/subFolder/file']);
1140 $this->assertEquals(
'/newFolder/subFolder/', $mappingInformation[
'/sourceFolder/subFolder/']);
1147 $this->setExpectedException(
'\\RuntimeException',
'', 1334160746);
1149 'sourceFolder' => array(
1153 $fixture = $this->createDriverFixture(array(), array(
'createIdentifierMap'));
1154 $fixture->expects($this->atLeastOnce())->method(
'createIdentifierMap')->will($this->throwException(
new \
TYPO3\CMS\Core\Resource\
Exception\FileOperationErrorException()));
1155 $fixture->renameFolder(
'/sourceFolder/',
'newFolder');
1156 $this->assertFileExists($this->
getUrlInMount(
'/sourceFolder/file'));
1165 'emptyFolder' => array()
1167 $fixture = $this->createDriverFixture();
1168 $this->assertTrue($fixture->isFolderEmpty(
'/emptyFolder/'));
1177 'folderWithFile' => array(
1181 $fixture = $this->createDriverFixture();
1182 $this->assertFalse($fixture->isFolderEmpty(
'/folderWithFile/'));
1190 'folderWithSubfolder' => array(
1191 'someFolder' => array()
1194 $fixture = $this->createDriverFixture();
1195 $this->assertFalse($fixture->isFolderEmpty(
'/folderWithSubfolder/'));
1204 public function foldersCanBeMovedWithinStorage() {
1207 'sourceFolder' => array(
1208 'file' => $fileContents,
1210 'targetFolder' => array(),
1212 $fixture = $this->createDriverFixture();
1214 $fixture->moveFolderWithinStorage(
'/sourceFolder/',
'/targetFolder/',
'someFolder');
1215 $this->assertTrue(file_exists($this->
getUrlInMount(
'/targetFolder/someFolder/')));
1216 $this->assertEquals($fileContents, file_get_contents($this->
getUrlInMount(
'/targetFolder/someFolder/file')));
1217 $this->assertFileNotExists($this->
getUrlInMount(
'/sourceFolder'));
1224 $fileContents =
'asdfg';
1226 'targetFolder' => array(),
1227 'sourceFolder' => array(
1228 'subFolder' => array(
'file' => $fileContents),
1232 $fixture = $this->createDriverFixture();
1233 $mappingInformation = $fixture->moveFolderWithinStorage(
'/sourceFolder/',
'/targetFolder/',
'sourceFolder');
1234 $this->assertEquals(
'/targetFolder/sourceFolder/file', $mappingInformation[
'/sourceFolder/file']);
1235 $this->assertEquals(
'/targetFolder/sourceFolder/subFolder/file', $mappingInformation[
'/sourceFolder/subFolder/file']);
1236 $this->assertEquals(
'/targetFolder/sourceFolder/subFolder/', $mappingInformation[
'/sourceFolder/subFolder/']);
1244 'sourceFolder' => array(
1247 'targetFolder' => array(),
1249 $fixture = $this->createDriverFixture();
1250 $fixture->moveFolderWithinStorage(
'/sourceFolder/',
'/targetFolder/',
'newFolder');
1251 $this->assertTrue(file_exists($this->
getUrlInMount(
'/targetFolder/newFolder/')));
1259 'sourceFolder' => array(
1262 'targetFolder' => array(),
1264 $fixture = $this->createDriverFixture();
1265 $fixture->copyFolderWithinStorage(
'/sourceFolder/',
'/targetFolder/',
'newFolderName');
1266 $this->assertTrue(is_file($this->
getUrlInMount(
'/targetFolder/newFolderName/file')));
1277 $fixture->copyFolderWithinStorage(
'/sourceFolder/',
'/targetFolder/',
'newFolderName');
1278 $this->isTrue(is_dir($basePath .
'/targetFolder/newFolderName/subFolder'));
1288 file_put_contents($basePath .
'/sourceFolder/subFolder/file', $this->
getUniqueId());
1291 $fixture->copyFolderWithinStorage(
'/sourceFolder/',
'/targetFolder/',
'newFolderName');
1292 $this->assertTrue(is_file($basePath .
'/targetFolder/newFolderName/subFolder/file'));
1304 $this->iso88591GreaterThan127 =
'';
1305 for ($i = 0xA0; $i <= 0xFF; $i++) {
1306 $this->iso88591GreaterThan127 .= chr($i);
1312 $this->utf8Latin1Supplement =
'';
1313 for ($i = 0xA0; $i <= 0xBF; $i++) {
1314 $this->utf8Latin1Supplement .= chr(0xC2) . chr($i);
1316 for ($i = 0x80; $i <= 0xBF; $i++) {
1317 $this->utf8Latin1Supplement .= chr(0xC3) . chr($i);
1321 $this->utf8Latin1ExtendedA =
'';
1322 for ($i = 0x80; $i <= 0xBF; $i++) {
1323 $this->utf8Latin1ExtendedA .= chr(0xC4) . chr($i);
1325 for ($i = 0x80; $i <= 0xBF; $i++) {
1326 $this->utf8Latin1ExtendedA .= chr(0xC5) . chr($i);
1344 'allowed characters utf-8 (ASCII part)' => array(
1345 '-.0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz',
1346 '-.0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz' 1349 'replace special characters with _ (not allowed characters) utf-8 (ASCII part)' => array(
1350 '! "#$%&\'()*+,/:;<=>?[\\]^`{|}~',
1351 '_____________________________' 1353 'utf-8 (Latin-1 Supplement)' => array(
1354 $this->utf8Latin1Supplement,
1355 '________________________________ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ' 1357 'trim leading and tailing spaces utf-8' => array(
1361 'remove tailing dot' => array(
1373 $GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'UTF8filesystem'] = 1;
1374 $this->assertEquals(
1376 $this->createDriverFixture()->sanitizeFileName($fileName)
1395 'allowed characters iso-8859-1' => array(
1396 '-.0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz',
1398 '-.0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz' 1401 'allowed characters utf-8' => array(
1402 '-.0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz',
1404 '-.0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz' 1407 'replace special characters with _ (not allowed characters) iso-8859-1' => array(
1408 '! "#$%&\'()*+,/:;<=>?[\\]^`{|}~',
1410 '_____________________________' 1413 'replace special characters with _ (not allowed characters) utf-8' => array(
1414 '! "#$%&\'()*+,/:;<=>?[\\]^`{|}~',
1416 '_____________________________' 1418 'iso-8859-1 (code > 127)' => array(
1421 $this->iso88591GreaterThan127,
1423 '_centpound_yen____c_a_____R_____-23_u___1o__1_41_23_4_AAAAAEAAAECEEEEIIIIDNOOOOOExOEUUUUEYTHssaaaaaeaaaeceeeeiiiidnoooooe_oeuuuueythy' 1425 'utf-8 (Latin-1 Supplement)' => array(
1427 $this->utf8Latin1Supplement,
1429 '_centpound__yen______c_a_______R_______-23__u_____1o__1_41_23_4_AAAAAEAAAECEEEEIIIIDNOOOOOExOEUUUUEYTHssaaaaaeaaaeceeeeiiiidnoooooe_oeuuuueythy' 1431 'utf-8 (Latin-1 Extended A)' => array(
1432 $this->utf8Latin1ExtendedA,
1434 'AaAaAaCcCcCcCcDdDdEeEeEeEeEeGgGgGgGgHhHhIiIiIiIiIiIJijJjKk__LlLlLlL_l_LlNnNnNn_n____OOooOoOoOEoeRrRrRrSsSsSsSsTtTtTtUuUuUuUuUuUuWwYyYZzZzZzs' 1436 'trim leading and tailing spaces iso-8859-1' => array(
1441 'trim leading and tailing spaces utf-8' => array(
1446 'remove tailing dot iso-8859-1' => array(
1451 'remove tailing dot utf-8' => array(
1464 $GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'UTF8filesystem'] = 0;
1465 $this->assertEquals(
1467 $this->createDriverFixture()->sanitizeFileName($fileName, $charset)
1476 $GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'UTF8filesystem'] = 1;
1477 $this->createDriverFixture()->sanitizeFileName(
'');
1484 $this->setExpectedException(
'Exception',
'I was called!');
1485 $closure =
function() {
1486 throw new \Exception(
'I was called!');
1489 $filterMethods = array(
1493 $this->createDriverFixture()->_call(
'applyFilterMethodsToDirectoryItem', $filterMethods,
'',
'',
'');
1500 $dummyObject = $this
1501 ->getMockBuilder(
'\TYPO3\CMS\Core\Resource\Driver\LocalDriver')
1502 ->setMethods(array(
'dummy'))
1503 ->disableOriginalConstructor()
1509 $dummyObject->expects($this->once())->method(
'dummy');
1510 $filterMethods = array(
1513 $this->createDriverFixture()->_call(
'applyFilterMethodsToDirectoryItem', $filterMethods,
'',
'',
'');
getFolderListReturnsHiddenFoldersByDefault()
static createFolderSanitizesFolderNameBeforeCreationDataProvider()
hashReturnsCorrectHashes()
defaultLevelFolderFolderIsCreatedIfItDoesntExist()
copyFolderWithinStorageCopiesSingleSubFolderToNewFolderName()
static mkdir_deep($directory, $deepDirectory='')
filesCanBeMovedWithinStorage()
getFolderListFailsIfDirectoryDoesNotExist()
renamingFolders_dataProvider()
getFileListFiltersItemsWithGivenFilterMethods()
addFileMovesFileToCorrectLocation()
getFileForLocalProcessingCreatesCopyOfFileByDefault()
getFileListReturnsAllFilesInDirectory()
existenceChecksInFolderWorkForFilesAndFolders()
static callbackStaticTestFunction()
fileContentsCanBeWrittenAndRead()
getFileForLocalProcessingReturnsOriginalFilepathForReadonlyAccess()
renameFolderRevertsRenamingIfFilenameMapCannotBeCreated()
static rmdir($path, $removeNonEmpty=FALSE)
existenceChecksWorkForFilesAndFolders()
sanitizeFileNameNonUTF8Filesystem($fileName, $charset, $expectedResult)
static fixPermissions($path, $recursive=FALSE)
getFileReturnsCorrectIdentifier()
renameFolderReturnsCorrectMappingInformationForAllFiles()
addFileReturnsFileIdentifier()
calculatedBasePathRelativeIsSane()
getFilePermissionsReturnsCorrectPermissionsForFilesNotOwnedByCurrentUser_dataProvider()
renamingFilesChangesFilenameOnDisk(array $filesystemStructure, $oldFileIdentifier, $newFileName, $expectedNewIdentifier)
isWithinRecognizesFilesWithinFolderAndInOtherFolders()
addFileUsesFilenameIfGiven()
getFileListFailsIfDirectoryDoesNotExist()
addToMount(array $dirStructure)
isWithinAcceptsFileAndFolderObjectsAsContent()
sanitizeFileNameNonUTF8FilesystemDataProvider()
filesCanBeCopiedWithinStorage()
basePathIsNormalizedWithTrailingSlash()
getFileThrowsExceptionIfFileDoesNotExist()
renamingFoldersChangesFolderNameOnDisk(array $filesystemStructure, $oldFolderIdentifier, $newFolderName, $expectedNewIdentifier)
renamingFiles_dataProvider()
getDefaultFolderReturnsFolderForUserUploadPath()
setFileContentsReturnsNumberOfBytesWrittenToFile()
renamingFilesFailsIfTargetFileExists()
isFolderEmptyReturnsFalseIfFolderHasSubfolder()
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)
addToVfs(array $dirStructure)
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren't numeric.
getFolderInFolderReturnsCorrectFolderObject()
getFileListReturnsAllFilesInSubdirectoryIfRecursiveParameterIsSet()
moveFolderWithinStorageReturnsCorrectMappingInformationForAllFiles()
applyFilterMethodsToDirectoryItemCallsFilterMethodIfClosure()
calculatedBasePathAbsoluteIsSane()
applyFilterMethodsToDirectoryItemCallsFilterMethodIfName()
getPublicUrlReturnsValidUrlContainingSpecialCharacters_dataProvider()
isFolderEmptyReturnsTrueForEmptyFolder()
static fixWindowsFilePath($theFile)
getPublicUrlReturnsCorrectUriForConfiguredBaseUri()
createFolderCreatesFolderOnDisk()
fileMetadataIsChangedAfterMovingFile()
getFolderListFiltersItemsWithGivenFilterMethods()
getFileInFolderCallsConfiguredCallbackFunctionWithGivenItemName()
copyFolderWithinStorageCopiesSingleFileToNewFolderName()
getFilesInFolderReturnsEmptyArrayForEmptyDirectory()
sanitizeFileNameUTF8FilesystemDataProvider()
folderCanBeRenamedWhenMoving()
getFolderListReturnsAllDirectoriesInDirectory()
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
noSecondSlashIsAddedIfBasePathAlreadyHasTrailingSlash()
createFolderSanitizesFolderNameBeforeCreation($newFolderName, $expectedFolderName)
getAbsolutePathReturnsCorrectPath()
filesCanBeCopiedToATemporaryPath()
getFolderListLeavesOutNavigationalEntries()
isFolderEmptyReturnsFalseIfFolderHasFile()
sanitizeFileNameThrowsExceptionOnInvalidFileName()
getPublicUrlReturnsValidUrlContainingSpecialCharacters($fileIdentifier)
createFolderReturnsFolderObject()
prepareRealTestEnvironment()
sanitizeFileNameUTF8Filesystem($fileName, $expectedResult)
addFileFailsIfFileIsInDriverStorage()
copyFolderWithinStorageCopiesFileInSingleSubFolderToNewFolderName()
hashingWithUnsupportedAlgorithmFails()