TYPO3 CMS  TYPO3_6-2
ResourceStorageTest.php
Go to the documentation of this file.
1 <?php
3 
6 
26 
30  protected $singletonInstances = array();
31 
35  protected $fixture;
36 
37  public function setUp() {
38  parent::setUp();
41  'TYPO3\\CMS\\Core\\Resource\\FileRepository',
42  $this->getMock('TYPO3\\CMS\\Core\\Resource\\FileRepository')
43  );
44  $databaseMock = $this->getMock('TYPO3\\CMS\Core\\Database\\DatabaseConnection');
45  $databaseMock->expects($this->any())->method('exec_SELECTgetRows')->with('*', 'sys_file_storage', '1=1', '', 'name', '', 'uid')->willReturn(array());
46  $GLOBALS['TYPO3_DB'] = $databaseMock;
47  }
48 
49  public function tearDown() {
51  parent::tearDown();
52  }
53 
61  protected function prepareFixture($configuration, $mockPermissionChecks = FALSE, $driverObject = NULL, array $storageRecord = array()) {
62  $permissionMethods = array('assureFileAddPermissions', 'checkFolderActionPermission', 'checkFileActionPermission', 'checkUserActionPermission', 'checkFileExtensionPermission', 'isWithinFileMountBoundaries');
63  $mockedMethods = array();
64  $configuration = $this->convertConfigurationArrayToFlexformXml($configuration);
65  $overruleArray = array('configuration' => $configuration);
67  if ($driverObject == NULL) {
69  $driverObject = $this->getMockForAbstractClass('TYPO3\\CMS\\Core\\Resource\\Driver\\AbstractDriver', array(), '', FALSE);
70  }
71  if ($mockPermissionChecks) {
72  $mockedMethods = $permissionMethods;
73  }
74  $mockedMethods[] = 'getIndexer';
75 
76  $this->fixture = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', $mockedMethods, array($driverObject, $storageRecord));
77  $this->fixture->expects($this->any())->method('getIndexer')->will($this->returnValue($this->getMock('TYPO3\CMS\Core\Resource\Index\Indexer', array(), array(), '', FALSE)));
78  foreach ($permissionMethods as $method) {
79  $this->fixture->expects($this->any())->method($method)->will($this->returnValue(TRUE));
80  }
81  }
82 
90  protected function convertConfigurationArrayToFlexformXml(array $configuration) {
91  $flexformArray = array('data' => array('sDEF' => array('lDEF' => array())));
92  foreach ($configuration as $key => $value) {
93  $flexformArray['data']['sDEF']['lDEF'][$key] = array('vDEF' => $value);
94  }
95  $configuration = \TYPO3\CMS\Core\Utility\GeneralUtility::array2xml($flexformArray);
96  return $configuration;
97  }
98 
109  protected function createDriverMock($driverConfiguration, \TYPO3\CMS\Core\Resource\ResourceStorage $storageObject = NULL, $mockedDriverMethods = array()) {
110  $this->initializeVfs();
111 
112  if (!isset($driverConfiguration['basePath'])) {
113  $driverConfiguration['basePath'] = $this->getMountRootUrl();
114  }
115 
116  if ($mockedDriverMethods === NULL) {
117  $driver = new \TYPO3\CMS\Core\Resource\Driver\LocalDriver($driverConfiguration);
118  } else {
119  // We are using the LocalDriver here because PHPUnit can't mock concrete methods in abstract classes, so
120  // when using the AbstractDriver we would be in trouble when wanting to mock away some concrete method
121  $driver = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Driver\\LocalDriver', $mockedDriverMethods, array($driverConfiguration));
122  }
123  if ($storageObject !== NULL) {
124  $storageObject->setDriver($driver);
125  }
126  $driver->setStorageUid(6);
127  $driver->processConfiguration();
128  $driver->initialize();
129  return $driver;
130  }
131 
136  return array(
137  'Permissions evaluated, extension not in allowed list' => array(
138  'fileName' => 'foo.txt',
139  'configuration' => array('allow' => 'jpg'),
140  'evaluatePermissions' => TRUE,
141  'isAllowed' => TRUE,
142  ),
143  'Permissions evaluated, extension in deny list' => array(
144  'fileName' => 'foo.txt',
145  'configuration' => array('deny' => 'txt'),
146  'evaluatePermissions' => TRUE,
147  'isAllowed' => FALSE,
148  ),
149  'Permissions not evaluated, extension is php' => array(
150  'fileName' => 'foo.php',
151  'configuration' => array(),
152  'evaluatePermissions' => FALSE,
153  'isAllowed' => FALSE,
154  ),
155  'Permissions evaluated, extension is php' => array(
156  'fileName' => 'foo.php',
157  // It is not possible to allow php file extension through configuration
158  'configuration' => array('allow' => 'php'),
159  'evaluatePermissions' => TRUE,
160  'isAllowed' => FALSE,
161  ),
162  );
163  }
164 
173  public function fileExtensionPermissionIsWorkingCorrectly($fileName, array $configuration, $evaluatePermissions, $isAllowed) {
174  $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']['webspace'] = $configuration;
175  $driverMock = $this->getMockForAbstractClass('TYPO3\\CMS\\Core\\Resource\\Driver\\AbstractDriver', array(), '', false);
176  $subject = $this->getAccessibleMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array('dummy'), array($driverMock, array()));
177  $subject->_set('evaluatePermissions', $evaluatePermissions);
178  $this->assertSame($isAllowed, $subject->_call('checkFileExtensionPermission', $fileName));
179  }
180 
185  return array(
186  'Access to file in ro file mount denied for write request' => array(
187  '$fileIdentifier' => '/fooBaz/bar.txt',
188  '$fileMountFolderIdentifier' => '/fooBaz/',
189  '$isFileMountReadOnly' => TRUE,
190  '$checkWriteAccess' => TRUE,
191  '$expectedResult' => FALSE,
192  ),
193  'Access to file in ro file mount allowed for read request' => array(
194  '$fileIdentifier' => '/fooBaz/bar.txt',
195  '$fileMountFolderIdentifier' => '/fooBaz/',
196  '$isFileMountReadOnly' => TRUE,
197  '$checkWriteAccess' => FALSE,
198  '$expectedResult' => TRUE,
199  ),
200  'Access to file in rw file mount allowed for write request' => array(
201  '$fileIdentifier' => '/fooBaz/bar.txt',
202  '$fileMountFolderIdentifier' => '/fooBaz/',
203  '$isFileMountReadOnly' => FALSE,
204  '$checkWriteAccess' => TRUE,
205  '$expectedResult' => TRUE,
206  ),
207  'Access to file in rw file mount allowed for read request' => array(
208  '$fileIdentifier' => '/fooBaz/bar.txt',
209  '$fileMountFolderIdentifier' => '/fooBaz/',
210  '$isFileMountReadOnly' => FALSE,
211  '$checkWriteAccess' => FALSE,
212  '$expectedResult' => TRUE,
213  ),
214  'Access to file not in file mount denied for write request' => array(
215  '$fileIdentifier' => '/fooBaz/bar.txt',
216  '$fileMountFolderIdentifier' => '/barBaz/',
217  '$isFileMountReadOnly' => FALSE,
218  '$checkWriteAccess' => TRUE,
219  '$expectedResult' => FALSE,
220  ),
221  'Access to file not in file mount denied for read request' => array(
222  '$fileIdentifier' => '/fooBaz/bar.txt',
223  '$fileMountFolderIdentifier' => '/barBaz/',
224  '$isFileMountReadOnly' => FALSE,
225  '$checkWriteAccess' => FALSE,
226  '$expectedResult' => FALSE,
227  ),
228  );
229  }
230 
241  public function isWithinFileMountBoundariesRespectsReadOnlyFileMounts($fileIdentifier, $fileMountFolderIdentifier, $isFileMountReadOnly, $checkWriteAccess, $expectedResult) {
243  $driverMock = $this->getMockForAbstractClass('TYPO3\\CMS\\Core\\Resource\\Driver\\AbstractDriver', array(), '', FALSE);
244  $driverMock->expects($this->any())
245  ->method('getFolderInfoByIdentifier')
246  ->willReturnCallback(function($identifier) use ($isFileMountReadOnly) {
247  return array(
248  'identifier' => $identifier,
249  'name' => trim($identifier, '/'),
250  );
251  });
252  $driverMock->expects($this->any())
253  ->method('isWithin')
254  ->willReturnCallback(function($folderIdentifier, $fileIdentifier) {
255  if ($fileIdentifier === ResourceStorageInterface::DEFAULT_ProcessingFolder . '/') {
256  return FALSE;
257  } else {
258  return strpos($fileIdentifier, $folderIdentifier) === 0;
259  }
260  });
261  $this->prepareFixture(array(), FALSE, $driverMock);
262  $fileMock = $this->getSimpleFileMock($fileIdentifier);
263  $this->fixture->setEvaluatePermissions(TRUE);
264  $this->fixture->addFileMount('/' . $this->getUniqueId('random') . '/', array('read_only' => FALSE));
265  $this->fixture->addFileMount($fileMountFolderIdentifier, array('read_only' => $isFileMountReadOnly));
266  $this->fixture->addFileMount('/' . $this->getUniqueId('random') . '/', array('read_only' => FALSE));
267  $this->assertSame($expectedResult, $this->fixture->isWithinFileMountBoundaries($fileMock, $checkWriteAccess));
268  }
269 
273  public function capabilitiesDataProvider() {
274  return array(
275  'only public' => array(
276  array(
277  'public' => TRUE,
278  'writable' => FALSE,
279  'browsable' => FALSE
280  )
281  ),
282  'only writable' => array(
283  array(
284  'public' => FALSE,
285  'writable' => TRUE,
286  'browsable' => FALSE
287  )
288  ),
289  'only browsable' => array(
290  array(
291  'public' => FALSE,
292  'writable' => FALSE,
293  'browsable' => TRUE
294  )
295  ),
296  'all capabilities' => array(
297  array(
298  'public' => TRUE,
299  'writable' => TRUE,
300  'browsable' => TRUE
301  )
302  ),
303  'none' => array(
304  array(
305  'public' => FALSE,
306  'writable' => FALSE,
307  'browsable' => FALSE
308  )
309  )
310  );
311  }
312 
318  public function capabilitiesOfStorageObjectAreCorrectlySet(array $capabilities) {
319  $this->markTestSkipped('This test does way to much and is mocked incomplete. Skipped for now.');
320  $storageRecord = array(
321  'is_public' => $capabilities['public'],
322  'is_writable' => $capabilities['writable'],
323  'is_browsable' => $capabilities['browsable'],
324  'is_online' => TRUE
325  );
326  $mockedDriver = $this->createDriverMock(
327  array(
328  'pathType' => 'relative',
329  'basePath' => 'fileadmin/',
330  ),
331  $this->fixture,
332  NULL
333  );
334  $this->prepareFixture(array(), FALSE, $mockedDriver, $storageRecord);
335  $this->assertEquals($capabilities['public'], $this->fixture->isPublic(), 'Capability "public" is not correctly set.');
336  $this->assertEquals($capabilities['writable'], $this->fixture->isWritable(), 'Capability "writable" is not correctly set.');
337  $this->assertEquals($capabilities['browsable'], $this->fixture->isBrowsable(), 'Capability "browsable" is not correctly set.');
338  }
339 
345  $this->markTestSkipped('This test does way to much and is mocked incomplete. Skipped for now.');
346  $this->prepareFixture(array());
347  $this->assertEquals($GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['defaultFilterCallbacks'], $this->fixture->getFileAndFolderNameFilters());
348  }
349 
353  public function addFileFailsIfFileDoesNotExist() {
354  $mockedFolder = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Folder', array(), array(), '', FALSE);
355  $this->setExpectedException('InvalidArgumentException', '', 1319552745);
356  $this->prepareFixture(array());
357  $this->fixture->addFile('/some/random/file', $mockedFolder);
358  }
359 
363  public function getPublicUrlReturnsNullIfStorageIsNotOnline() {
365  $driver = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Driver\\LocalDriver', array(), array(array('basePath' => $this->getMountRootUrl())));
367  $fixture = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array('isOnline'), array($driver, array('configuration' => array())));
368  $fixture->expects($this->once())->method('isOnline')->will($this->returnValue(FALSE));
369 
370  $sourceFileIdentifier = '/sourceFile.ext';
371  $sourceFile = $this->getSimpleFileMock($sourceFileIdentifier);
372  $result = $fixture->getPublicUrl($sourceFile);
373  $this->assertSame($result, NULL);
374  }
375 
382  return array(
383  'read action on readable/writable folder' => array(
384  'read',
385  array('r' => TRUE, 'w' => TRUE),
386  TRUE
387  ),
388  'read action on unreadable folder' => array(
389  'read',
390  array('r' => FALSE, 'w' => TRUE),
391  FALSE
392  ),
393  'write action on read-only folder' => array(
394  'write',
395  array('r' => TRUE, 'w' => FALSE),
396  FALSE
397  )
398  );
399  }
400 
408  public function checkFolderPermissionsRespectsFilesystemPermissions($action, $permissionsFromDriver, $expectedResult) {
409  $mockedDriver = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Driver\\LocalDriver');
410  $mockedDriver->expects($this->any())->method('getPermissions')->will($this->returnValue($permissionsFromDriver));
411  $mockedFolder = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Folder', array(), array(), '', FALSE);
412  // Let all other checks pass
414  $fixture = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array('isWritable', 'isBrowsable', 'checkUserActionPermission'), array($mockedDriver, array()), '', FALSE);
415  $fixture->expects($this->any())->method('isWritable')->will($this->returnValue(TRUE));
416  $fixture->expects($this->any())->method('isBrowsable')->will($this->returnValue(TRUE));
417  $fixture->expects($this->any())->method('checkUserActionPermission')->will($this->returnValue(TRUE));
418  $fixture->setDriver($mockedDriver);
419 
420  $this->assertSame($expectedResult, $fixture->checkFolderActionPermission($action, $mockedFolder));
421  }
422 
427  $this->prepareFixture(array());
428  $this->assertTrue($this->fixture->checkUserActionPermission('read', 'folder'));
429  }
430 
435  $this->prepareFixture(array());
436  $this->fixture->setUserPermissions(array('readFolder' => TRUE, 'writeFile' => TRUE));
437  $this->assertTrue($this->fixture->checkUserActionPermission('read', 'folder'));
438  }
439 
441  return array(
442  'all lower cased' => array(
443  array('readFolder' => TRUE),
444  'read',
445  'folder'
446  ),
447  'all upper case' => array(
448  array('readFolder' => TRUE),
449  'READ',
450  'FOLDER'
451  ),
452  'mixed case' => array(
453  array('readFolder' => TRUE),
454  'ReaD',
455  'FoLdEr'
456  )
457  );
458  }
459 
464  public function checkUserActionPermissionAcceptsArbitrarilyCasedArguments($permissions, $action, $type) {
465  $this->prepareFixture(array());
466  $this->fixture->setUserPermissions($permissions);
467  $this->assertTrue($this->fixture->checkUserActionPermission($action, $type));
468  }
469 
474  $this->prepareFixture(array());
475  $this->fixture->setEvaluatePermissions(TRUE);
476  $this->fixture->setUserPermissions(array('readFolder' => FALSE));
477  $this->assertFalse($this->fixture->checkUserActionPermission('read', 'folder'));
478  }
479 
484  $this->prepareFixture(array());
485  $this->fixture->setEvaluatePermissions(TRUE);
486  $this->fixture->setUserPermissions(array('readFolder' => TRUE));
487  $this->assertFalse($this->fixture->checkUserActionPermission('write', 'folder'));
488  }
489 
494  $this->prepareFixture(array());
495  $this->fixture->setEvaluatePermissions(FALSE);
496  $this->assertFalse($this->fixture->getEvaluatePermissions());
497  }
498 
503  $this->prepareFixture(array());
504  $this->fixture->setEvaluatePermissions(TRUE);
505  $this->assertTrue($this->fixture->getEvaluatePermissions());
506  }
507 
514  $this->markTestSkipped('This test does way to much and is mocked incomplete. Skipped for now.');
515  $this->initializeVfs();
516  $driverObject = $this->getMockForAbstractClass('TYPO3\\CMS\\Core\\Resource\\Driver\\AbstractDriver', array(), '', FALSE);
517  $this->fixture = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array('getFileIndexRepository', 'checkFileActionPermission'), array($driverObject, array()));
518  $this->fixture->expects($this->any())->method('checkFileActionPermission')->will($this->returnValue(TRUE));
519  $fileInfo = array(
520  'storage' => 'A',
521  'identifier' => 'B',
522  'mtime' => 'C',
523  'ctime' => 'D',
524  'mimetype' => 'E',
525  'size' => 'F',
526  'name' => 'G',
527  );
528  $newProperties = array(
529  'storage' => $fileInfo['storage'],
530  'identifier' => $fileInfo['identifier'],
531  'tstamp' => $fileInfo['mtime'],
532  'crdate' => $fileInfo['ctime'],
533  'mime_type' => $fileInfo['mimetype'],
534  'size' => $fileInfo['size'],
535  'name' => $fileInfo['name']
536  );
537  $hash = 'asdfg';
538  $driver = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Driver\\LocalDriver', array(), array(array('basePath' => $this->getMountRootUrl())));
539  $driver->expects($this->once())->method('getFileInfoByIdentifier')->will($this->returnValue($fileInfo));
540  $driver->expects($this->once())->method('hash')->will($this->returnValue($hash));
541  $this->fixture->setDriver($driver);
542  $indexFileRepositoryMock = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Index\\FileIndexRepository');
543  $this->fixture->expects($this->any())->method('getFileIndexRepository')->will($this->returnValue($indexFileRepositoryMock));
544  $mockedFile = $this->getMock('TYPO3\\CMS\\Core\\Resource\\File', array(), array(), '', FALSE);
545  $mockedFile->expects($this->any())->method('getIdentifier')->will($this->returnValue($fileInfo['identifier']));
546  // called by indexer because the properties are updated
547  $this->fixture->expects($this->any())->method('getFileInfoByIdentifier')->will($this->returnValue($newProperties));
548  $mockedFile->expects($this->any())->method('getStorage')->will($this->returnValue($this->fixture));
549  $mockedFile->expects($this->any())->method('getProperties')->will($this->returnValue(array_keys($fileInfo)));
550  $mockedFile->expects($this->any())->method('getUpdatedProperties')->will($this->returnValue(array_keys($newProperties)));
551  // do not update directly; that's up to the indexer
552  $indexFileRepositoryMock->expects($this->never())->method('update');
553  $this->fixture->setFileContents($mockedFile, $this->getUniqueId());
554  }
555 
561  public function moveFileCallsDriversMethodsWithCorrectArguments() {
562  $this->markTestSkipped('This test does way to much and is mocked incomplete. Skipped for now.');
563  $localFilePath = '/path/to/localFile';
564  $sourceFileIdentifier = '/sourceFile.ext';
565  $fileInfoDummy = array(
566  'storage' => 'A',
567  'identifier' => 'B',
568  'mtime' => 'C',
569  'ctime' => 'D',
570  'mimetype' => 'E',
571  'size' => 'F',
572  'name' => 'G',
573  );
574  $this->addToMount(array(
575  'targetFolder' => array()
576  ));
577  $this->initializeVfs();
578  $targetFolder = $this->getSimpleFolderMock('/targetFolder/');
579  $sourceDriver = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Driver\\LocalDriver');
580  $sourceDriver->expects($this->once())->method('deleteFile')->with($this->equalTo($sourceFileIdentifier));
581  $configuration = $this->convertConfigurationArrayToFlexformXml(array());
582  $sourceStorage = new \TYPO3\CMS\Core\Resource\ResourceStorage($sourceDriver, array('configuration' => $configuration));
583  $sourceFile = $this->getSimpleFileMock($sourceFileIdentifier);
584  $sourceFile->expects($this->once())->method('getForLocalProcessing')->will($this->returnValue($localFilePath));
585  $sourceFile->expects($this->any())->method('getStorage')->will($this->returnValue($sourceStorage));
586  $sourceFile->expects($this->once())->method('getUpdatedProperties')->will($this->returnValue(array_keys($fileInfoDummy)));
587  $sourceFile->expects($this->once())->method('getProperties')->will($this->returnValue($fileInfoDummy));
589  $driver = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Driver\\LocalDriver', array(), array(array('basePath' => $this->getMountRootUrl())));
590  $driver->expects($this->once())->method('getFileInfoByIdentifier')->will($this->returnValue($fileInfoDummy));
591  $driver->expects($this->once())->method('addFile')->with($localFilePath, '/targetFolder/', $this->equalTo('file.ext'))->will($this->returnValue('/targetFolder/file.ext'));
593  $fixture = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array('assureFileMovePermissions'), array($driver, array('configuration' => $configuration)));
594  $fixture->moveFile($sourceFile, $targetFolder, 'file.ext');
595  }
596 
603  $this->markTestSkipped('This test does way to much and is mocked incomplete. Skipped for now.');
604  $mockedFile = $this->getSimpleFileMock('/mountFolder/file');
605  $this->addToMount(array(
606  'mountFolder' => array(
607  'file' => 'asdfg'
608  )
609  ));
610  $mockedDriver = $this->createDriverMock(array('basePath' => $this->getMountRootUrl()), NULL, NULL);
611  $this->initializeVfs();
612  $this->prepareFixture(array(), NULL, $mockedDriver);
613  $this->fixture->addFileMount('/mountFolder');
614  $this->assertEquals(1, count($this->fixture->getFileMounts()));
615  $this->fixture->isWithinFileMountBoundaries($mockedFile);
616  }
617 
618 
624  $this->markTestSkipped('This test does way to much and is mocked incomplete. Skipped for now.');
625  $mockedParentFolder = $this->getSimpleFolderMock('/someFolder/');
626  $mockedDriver = $this->createDriverMock(array());
627  $mockedDriver->expects($this->once())->method('folderExists')->with($this->equalTo('/someFolder/'))->will($this->returnValue(TRUE));
628  $mockedDriver->expects($this->once())->method('createFolder')->with($this->equalTo('newFolder'))->will($this->returnValue($mockedParentFolder));
629  $this->prepareFixture(array(), TRUE);
630  $this->fixture->setDriver($mockedDriver);
631  $this->fixture->createFolder('newFolder', $mockedParentFolder);
632  }
633 
638  public function deleteFolderThrowsExceptionIfFolderIsNotEmptyAndRecursiveDeleteIsDisabled() {
640  $folderMock = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Folder', array(), array(), '', FALSE);
642  $driverMock = $this->getMockForAbstractClass('TYPO3\\CMS\\Core\\Resource\\Driver\\AbstractDriver');
643  $driverMock->expects($this->once())->method('isFolderEmpty')->will($this->returnValue(FALSE));
645  $fixture = $this->getAccessibleMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array('checkFolderActionPermission'), array(), '', FALSE);
646  $fixture->expects($this->any())->method('checkFolderActionPermission')->will($this->returnValue(TRUE));
647  $fixture->_set('driver', $driverMock);
648  $fixture->deleteFolder($folderMock, FALSE);
649  }
650 
656  $this->markTestSkipped('This test does way to much and is mocked incomplete. Skipped for now.');
657  $mockedParentFolder = $this->getSimpleFolderMock('/someFolder/');
658  $this->prepareFixture(array(), TRUE);
659  $mockedDriver = $this->createDriverMock(array(), $this->fixture);
660  $mockedDriver->expects($this->once())->method('createFolder')->with($this->equalTo('newFolder'), $this->equalTo('/someFolder/'))->will($this->returnValue(TRUE));
661  $mockedDriver->expects($this->once())->method('folderExists')->with($this->equalTo('/someFolder/'))->will($this->returnValue(TRUE));
662  $this->fixture->createFolder('newFolder', $mockedParentFolder);
663  }
664 
670  $this->markTestSkipped('This test does way to much and is mocked incomplete. Skipped for now.');
671  $this->addToMount(array('someFolder' => array()));
672  $mockedDriver = $this->createDriverMock(array('basePath' => $this->getMountRootUrl()), NULL, NULL);
673  $this->prepareFixture(array(), TRUE, $mockedDriver);
674  $parentFolder = $this->fixture->getFolder('/someFolder/');
675  $newFolder = $this->fixture->createFolder('subFolder/secondSubfolder', $parentFolder);
676  $this->assertEquals('secondSubfolder', $newFolder->getName());
677  $this->assertFileExists($this->getUrlInMount('/someFolder/subFolder/'));
678  $this->assertFileExists($this->getUrlInMount('/someFolder/subFolder/secondSubfolder/'));
679  }
680 
686  $this->markTestSkipped('This test does way to much and is mocked incomplete. Skipped for now.');
687  $this->prepareFixture(array(), TRUE);
688  $mockedDriver = $this->createDriverMock(array(), $this->fixture);
689  $mockedDriver->expects($this->once())->method('getRootLevelFolder')->with()->will($this->returnValue('/'));
690  $mockedDriver->expects($this->once())->method('createFolder')->with($this->equalTo('someFolder'));
691  $this->fixture->createFolder('someFolder');
692  }
693 
699  $this->markTestSkipped('This test does way to much and is mocked incomplete. Skipped for now.');
700  $this->addToMount(array(
701  'existingFolder' => array()
702  ));
703  $this->initializeVfs();
704  $mockedDriver = $this->createDriverMock(array('basePath' => $this->getMountRootUrl()), NULL, NULL);
705  $this->prepareFixture(array(), TRUE, $mockedDriver);
706  $rootFolder = $this->fixture->getFolder('/');
707  $newFolder = $this->fixture->createFolder('existingFolder/someFolder', $rootFolder);
708  $this->assertEquals('someFolder', $newFolder->getName());
709  $this->assertFileExists($this->getUrlInMount('existingFolder/someFolder'));
710  }
711 
716  $this->setExpectedException('InvalidArgumentException', '', 1325689164);
717  $mockedParentFolder = $this->getSimpleFolderMock('/someFolder/');
718  $this->prepareFixture(array(), TRUE);
719  $mockedDriver = $this->createDriverMock(array(), $this->fixture);
720  $mockedDriver->expects($this->once())->method('folderExists')->with($this->equalTo('/someFolder/'))->will($this->returnValue(FALSE));
721  $this->fixture->createFolder('newFolder', $mockedParentFolder);
722  }
723 
728  $this->setExpectedException('InvalidArgumentException', '', 1325842622);
729  $this->prepareFixture(array(), TRUE);
730  $mockedFile = $this->getSimpleFileMock('/someFile');
731  $this->fixture->replaceFile($mockedFile, PATH_site . $this->getUniqueId());
732  }
733 
739  $this->markTestSkipped('This test does way to much and is mocked incomplete. Skipped for now.');
740  $folderIdentifier = $this->getUniqueId();
741  $this->addToMount(array(
742  $folderIdentifier => array()
743  ));
744  $this->prepareFixture(array());
745 
746  $role = $this->fixture->getRole($this->getSimpleFolderMock('/' . $folderIdentifier . '/'));
747 
748  $this->assertSame(\TYPO3\CMS\Core\Resource\FolderInterface::ROLE_DEFAULT, $role);
749  }
750 }
getSimpleFolderMock($identifier, $mockedMethods=array())
static mergeRecursiveWithOverrule(array &$original, array $overrule, $addKeys=TRUE, $includeEmptyValues=TRUE, $enableUnsetFeature=TRUE)
static setSingletonInstance($className, \TYPO3\CMS\Core\SingletonInterface $instance)
$driver
Definition: server.php:34
getSimpleFileMock($identifier, $mockedMethods=array())
createDriverMock($driverConfiguration, \TYPO3\CMS\Core\Resource\ResourceStorage $storageObject=NULL, $mockedDriverMethods=array())
fileExtensionPermissionIsWorkingCorrectly($fileName, array $configuration, $evaluatePermissions, $isAllowed)
static array2xml(array $array, $NSprefix='', $level=0, $docTag='phparray', $spaceInd=0, array $options=array(), array $stackData=array())
static resetSingletonInstances(array $newSingletonInstances)
checkUserActionPermissionAcceptsArbitrarilyCasedArguments($permissions, $action, $type)
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren&#39;t numeric.
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]