[TASK] Namespace and move t3lib unit tests - 6
authorWouter Wolters <typo3@wouterwolters.nl>
Sun, 9 Sep 2012 14:05:13 +0000 (16:05 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sun, 9 Sep 2012 15:45:13 +0000 (17:45 +0200)
This patch moves most unit tests of the tests/Unit/t3lib/*
directory to the core extension, following the new name scheme.

Change-Id: Ia03bc00ccb256c68684f7243fea77804081cb287
Resolves: #40770
Related: #40095
Releases: 6.0
Reviewed-on: http://review.typo3.org/14475
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
32 files changed:
tests/Unit/t3lib/class.t3lib_arraybrowserTest.php [deleted file]
tests/Unit/t3lib/class.t3lib_cacheHashTest.php [deleted file]
tests/Unit/t3lib/class.t3lib_pageselectTest.php [deleted file]
tests/Unit/t3lib/file/BaseTestCase.php [deleted file]
tests/Unit/t3lib/file/Driver/AbstractDriverTest.php [deleted file]
tests/Unit/t3lib/file/Driver/DriverRegistryTest.php [deleted file]
tests/Unit/t3lib/file/Driver/Fixtures/Dummy.html [deleted file]
tests/Unit/t3lib/file/Driver/Fixtures/LocalDriverFilenameFilter.php [deleted file]
tests/Unit/t3lib/file/Driver/LocalDriverTest.php [deleted file]
tests/Unit/t3lib/file/FactoryTest.php [deleted file]
tests/Unit/t3lib/file/FileTest.php [deleted file]
tests/Unit/t3lib/file/FolderTest.php [deleted file]
tests/Unit/t3lib/file/Repository/AbstractRepositoryTest.php [deleted file]
tests/Unit/t3lib/file/Service/IndexerServiceTest.php [deleted file]
tests/Unit/t3lib/file/StorageTest.php [deleted file]
tests/Unit/t3lib/file/Utility/FileExtensionFilterTest.php [deleted file]
typo3/sysext/core/Tests/Unit/Resource/BaseTestCase.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Resource/Driver/AbstractDriverTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Resource/Driver/DriverRegistryTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Resource/Driver/Fixtures/Dummy.html [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Resource/Driver/Fixtures/LocalDriverFilenameFilter.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Resource/Driver/LocalDriverTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Resource/FactoryTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Resource/FileTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Resource/FolderTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Resource/Repository/AbstractRepositoryTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Resource/Service/IndexerServiceTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Resource/StorageTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Resource/Utility/FileExtensionFilterTest.php [new file with mode: 0644]
typo3/sysext/frontend/Tests/Unit/Page/CacheHashCalculatorTest.php [new file with mode: 0644]
typo3/sysext/frontend/Tests/Unit/Page/PageRepositoryTest.php [new file with mode: 0644]
typo3/sysext/integrity/Tests/Unit/Utility/ArrayBrowserTest.php [new file with mode: 0644]

diff --git a/tests/Unit/t3lib/class.t3lib_arraybrowserTest.php b/tests/Unit/t3lib/class.t3lib_arraybrowserTest.php
deleted file mode 100644 (file)
index f14122f..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-<?php
-/***************************************************************
- * Copyright notice
- *
- * (c) 2010-2011 Oliver Klee (typo3-coding@oliverklee.de)
- * All rights reserved
- *
- * This script is part of the TYPO3 project. The TYPO3 project is
- * free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * The GNU General Public License can be found at
- * http://www.gnu.org/copyleft/gpl.html.
- *
- * This script is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-/**
- * Testcase for the t3lib_arrayBrowser class in the TYPO3 Core.
- *
- * @package TYPO3
- * @subpackage t3lib
- * @author Oliver Klee <typo3-coding@oliverklee.de>
- */
-class t3lib_arrayBrowserTest extends tx_phpunit_testcase {
-
-       /**
-        * @var \TYPO3\CMS\Integrity\Utility\ArrayBrowser
-        */
-       private $fixture;
-
-       public function setUp() {
-               $this->fixture = new \TYPO3\CMS\Integrity\Utility\ArrayBrowser();
-       }
-
-       public function tearDown() {
-               unset($this->fixture);
-       }
-
-       ///////////////////////////////
-       // Tests concerning depthKeys
-       ///////////////////////////////
-       /**
-        * @test
-        */
-       public function depthKeysWithEmptyFirstParameterAddsNothing() {
-               $this->assertEquals(array(), $this->fixture->depthKeys(array(), array()));
-       }
-
-       /**
-        * @test
-        */
-       public function depthKeysWithNumericKeyAddsOneNumberForKeyFromFirstArray() {
-               $this->assertEquals(array(0 => 1), $this->fixture->depthKeys(array('foo'), array()));
-       }
-
-}
-
-?>
\ No newline at end of file
diff --git a/tests/Unit/t3lib/class.t3lib_cacheHashTest.php b/tests/Unit/t3lib/class.t3lib_cacheHashTest.php
deleted file mode 100644 (file)
index 48efff6..0000000
+++ /dev/null
@@ -1,257 +0,0 @@
-<?php
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2012 Tolleiv Nietsch <typo3@tolleiv.de>
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-/**
- * Testcase for class t3lib_cacheHeash
- *
- * @author 2012 Tolleiv Nietsch <typo3@tolleiv.de>
- * @package TYPO3
- * @subpackage t3lib
- */
-class t3lib_cacheHashTest extends tx_phpunit_testcase {
-
-       /**
-        * @var \TYPO3\CMS\Frontend\Page\CacheHashCalculator
-        */
-       protected $fixture;
-
-       /**
-        * @var array
-        */
-       protected $confCache = array();
-
-       public function setUp() {
-               $this->confCache = array(
-                       'encryptionKey' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']
-               );
-               $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = 't3lib_cacheHashTest';
-               $this->fixture = $this->getMock('TYPO3\\CMS\\Frontend\\Page\\CacheHashCalculator', array('foo'));
-               $this->fixture->setConfiguration(array(
-                       'excludedParameters' => array('exclude1', 'exclude2'),
-                       'cachedParametersWhiteList' => array(),
-                       'requireCacheHashPresenceParameters' => array('req1', 'req2'),
-                       'excludedParametersIfEmpty' => array(),
-                       'excludeAllEmptyParameters' => FALSE
-               ));
-       }
-
-       public function tearDown() {
-               $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = $this->confCache['encryptionKey'];
-       }
-
-       /**
-        * @dataProvider cacheHashCalculationDataprovider
-        * @test
-        */
-       public function cacheHashCalculationWorks($params, $expected) {
-               if (!class_exists('t3lib_diff')) {
-                       $this->markTestSkipped('The current version of phpunit relies on t3lib_diff which is removed in 6.0 and thus this test fails. Move t3lib_diff to phpunit and reenable this test.');
-               }
-               $this->assertEquals($expected, $this->fixture->calculateCacheHash($params));
-       }
-
-       /**
-        * @return array
-        */
-       public function cacheHashCalculationDataprovider() {
-               return array(
-                       'Empty parameters should not return a hash' => array(
-                               array(),
-                               ''
-                       ),
-                       'Trivial key value combination should generate hash' => array(
-                               array(
-                                       'encryptionKey' => 't3lib_cacheHashTest',
-                                       'key' => 'value'
-                               ),
-                               '5cfdcf826275558b3613dd51714a0a17'
-                       ),
-                       'Multiple parameters should generate hash' => array(
-                               array(
-                                       'a' => 'v',
-                                       'b' => 'v',
-                                       'encryptionKey' => 't3lib_cacheHashTest'
-                               ),
-                               '0f40b089cdad149aea99e9bf4badaa93'
-                       )
-               );
-       }
-
-       /**
-        * @dataProvider getRelevantParametersDataprovider
-        * @test
-        */
-       public function getRelevantParametersWorks($params, $expected) {
-               $actual = $this->fixture->getRelevantParameters($params);
-               $this->assertEquals($expected, array_keys($actual));
-       }
-
-       /**
-        * @return array
-        */
-       public function getRelevantParametersDataprovider() {
-               return array(
-                       'Empty list should be passed through' => array('', array()),
-                       'Simple parameter should be passed through and the encryptionKey should be added' => array(
-                               'key=v',
-                               array('encryptionKey', 'key')
-                       ),
-                       'Simple parameter should be passed through' => array(
-                               'key1=v&key2=v',
-                               array('encryptionKey', 'key1', 'key2')
-                       ),
-                       'System and exclude paramters should be omitted' => array(
-                               'id=1&type=3&exclude1=x&no_cache=1',
-                               array()
-                       ),
-                       'System and exclude paramters should be omitted' => array(
-                               'id=1&type=3&key=x&no_cache=1',
-                               array('encryptionKey', 'key')
-                       )
-               );
-       }
-
-       /**
-        * @dataProvider canGenerateForParametersDataprovider
-        * @test
-        */
-       public function canGenerateForParameters($params, $expected) {
-               if (!class_exists('t3lib_diff')) {
-                       $this->markTestSkipped('The current version of phpunit relies on t3lib_diff which is removed in 6.0 and thus this test fails. Move t3lib_diff to phpunit and reenable this test.');
-               }
-               $this->assertEquals($expected, $this->fixture->generateForParameters($params));
-       }
-
-       /**
-        * @return array
-        */
-       public function canGenerateForParametersDataprovider() {
-               $knowHash = '5cfdcf826275558b3613dd51714a0a17';
-               return array(
-                       'Empty parameters should not return an hash' => array('', ''),
-                       'Querystring has no relevant parameters so we should not have a cacheHash' => array('&exclude1=val', ''),
-                       'Querystring has only system parameters so we should not have a cacheHash' => array('id=1&type=val', ''),
-                       'Trivial key value combination should generate hash' => array('&key=value', $knowHash),
-                       'Only the relevant parts should be taken into account' => array('&key=value&exclude1=val', $knowHash),
-                       'Only the relevant parts should be taken into account' => array('&exclude2=val&key=value', $knowHash),
-                       'System parameters should not be taken into account' => array('&id=1&key=value', $knowHash),
-                       'Admin panel parameters should not be taken into account' => array('&TSFE_ADMIN_PANEL[display]=7&key=value', $knowHash),
-                       'Trivial hash for sorted parameters should be right' => array('a=v&b=v', '0f40b089cdad149aea99e9bf4badaa93'),
-                       'Parameters should be sorted before  is created' => array('b=v&a=v', '0f40b089cdad149aea99e9bf4badaa93')
-               );
-       }
-
-       /**
-        * @dataProvider parametersRequireCacheHashDataprovider
-        * @test
-        */
-       public function parametersRequireCacheHashWorks($params, $expected) {
-               $this->assertEquals($expected, $this->fixture->doParametersRequireCacheHash($params));
-       }
-
-       /**
-        * @return array
-        */
-       public function parametersRequireCacheHashDataprovider() {
-               return array(
-                       'Empty parameter strings should not require anything.' => array('', FALSE),
-                       'Normal parameters aren\'t required.' => array('key=value', FALSE),
-                       'Configured "req1" to be required.' => array('req1=value', TRUE),
-                       'Configured "req1" to be requiredm, should also work in combined context' => array('&key=value&req1=value', TRUE),
-                       'Configured "req1" to be requiredm, should also work in combined context' => array('req1=value&key=value', TRUE)
-               );
-       }
-
-       /**
-        * In case the cHashOnlyForParameters is set, other parameters should not
-        * incluence the cHash (except the encryption key of course)
-        *
-        * @dataProvider canWhitelistParametersDataprovider
-        * @test
-        */
-       public function canWhitelistParameters($params, $expected) {
-               if (!class_exists('t3lib_diff')) {
-                       $this->markTestSkipped('The current version of phpunit relies on t3lib_diff which is removed in 6.0 and thus this test fails. Move t3lib_diff to phpunit and reenable this test.');
-               }
-               $method = new ReflectionMethod('TYPO3\\CMS\\Frontend\\Page\\CacheHashCalculator', 'setCachedParametersWhiteList');
-               $method->setAccessible(TRUE);
-               $method->invoke($this->fixture, array('whitep1', 'whitep2'));
-               $this->assertEquals($expected, $this->fixture->generateForParameters($params));
-       }
-
-       /**
-        * @return array
-        */
-       public function canWhitelistParametersDataprovider() {
-               $oneParamHash = 'e2c0f2edf08be18bcff2f4272e11f66b';
-               $twoParamHash = 'f6f08c2e10a97d91b6ec61a6e2ddd0e7';
-               return array(
-                       'Even with the whitelist enabled, empty parameters should not return an hash.' => array('', ''),
-                       'Whitelisted parameters should have a hash.' => array('whitep1=value', $oneParamHash),
-                       'Blacklisted parameter should not influence hash.' => array('whitep1=value&black=value', $oneParamHash),
-                       'Multiple whitelisted parameters should work' => array('&whitep1=value&whitep2=value', $twoParamHash),
-                       'The order should not influce the hash.' => array('whitep2=value&black=value&whitep1=value', $twoParamHash)
-               );
-       }
-
-       /**
-        * @dataProvider canSkipParametersWithEmptyValuesDataprovider
-        * @test
-        */
-       public function canSkipParametersWithEmptyValues($params, $settings, $expected) {
-               $this->fixture->setConfiguration($settings);
-               $actual = $this->fixture->getRelevantParameters($params);
-               $this->assertEquals($expected, array_keys($actual));
-       }
-
-       /**
-        * @return array
-        */
-       public function canSkipParametersWithEmptyValuesDataprovider() {
-               return array(
-                       'The default configuration does not allow to skip an empty key.' => array(
-                               'key1=v&key2=&key3=',
-                               array('excludedParametersIfEmpty' => array(), 'excludeAllEmptyParameters' => FALSE),
-                               array('encryptionKey', 'key1', 'key2', 'key3')
-                       ),
-                       'Due to the empty value, "key2" should be skipped' => array(
-                               'key1=v&key2=&key3=',
-                               array('excludedParametersIfEmpty' => array('key2'), 'excludeAllEmptyParameters' => FALSE),
-                               array('encryptionKey', 'key1', 'key3')
-                       ),
-                       'Due to the empty value, "key2" should be skipped' => array(
-                               'key1=v&key2&key3',
-                               array('excludedParametersIfEmpty' => array('key2'), 'excludeAllEmptyParameters' => FALSE),
-                               array('encryptionKey', 'key1', 'key3')
-                       ),
-                       'Due to the empty value, "key2" and "key3" should be skipped' => array(
-                               'key1=v&key2=&key3=',
-                               array('excludedParametersIfEmpty' => array(), 'excludeAllEmptyParameters' => TRUE),
-                               array('encryptionKey', 'key1')
-                       )
-               );
-       }
-
-}
-
-?>
\ No newline at end of file
diff --git a/tests/Unit/t3lib/class.t3lib_pageselectTest.php b/tests/Unit/t3lib/class.t3lib_pageselectTest.php
deleted file mode 100644 (file)
index 65797e9..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-<?php
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2009-2011 Christian Kuhn <lolli@schwarzbu.ch>
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-/**
- * Testcase for class t3lib_page
- *
- * @author Christian Kuhn <lolli@schwarzbu.ch>
- * @author Oliver Klee <typo3-coding@oliverklee.de>
- * @package TYPO3
- * @subpackage t3lib
- */
-class t3lib_pageselectTest extends tx_phpunit_testcase {
-
-       /**
-        * @var \TYPO3\CMS\Core\Database\DatabaseConnection
-        */
-       protected $typo3DbBackup;
-
-       /**
-        * @var \TYPO3\CMS\Frontend\Page\PageRepository
-        */
-       protected $pageSelectObject;
-
-       /**
-        * Sets up this testcase
-        */
-       public function setUp() {
-               $this->typo3DbBackup = $GLOBALS['TYPO3_DB'];
-               $GLOBALS['TYPO3_DB'] = $this->getMock('TYPO3\\CMS\\Core\\Database\\DatabaseConnection', array('exec_SELECTquery', 'sql_fetch_assoc', 'sql_free_result'));
-               $this->pageSelectObject = new \TYPO3\CMS\Frontend\Page\PageRepository();
-       }
-
-       /**
-        * Tears down this testcase
-        */
-       public function tearDown() {
-               $GLOBALS['TYPO3_DB'] = $this->typo3DbBackup;
-       }
-
-       /**
-        * Tests whether the getPage Hook is called correctly.
-        *
-        * @test
-        */
-       public function isGetPageHookCalled() {
-               // Create a hook mock object
-               $className = uniqid('tx_coretest');
-               $getPageHookMock = $this->getMock('TYPO3\\CMS\\Frontend\\Page\\PageRepositoryGetPageHookInterface', array('getPage_preProcess'), array(), $className);
-               // Register hook mock object
-               $GLOBALS['T3_VAR']['getUserObj'][$className] = $getPageHookMock;
-               $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_page.php']['getPage'][] = $className;
-               // Test if hook is called and register a callback method to check given arguments
-               $getPageHookMock->expects($this->once())->method('getPage_preProcess')->will($this->returnCallback(array($this, 'isGetPagePreProcessCalledCallback')));
-               $this->pageSelectObject->getPage(42, FALSE);
-       }
-
-       /**
-        * Handles the arguments that have been sent to the getPage_preProcess hook
-        */
-       public function isGetPagePreProcessCalledCallback() {
-               list($uid, $disableGroupAccessCheck, $parent) = func_get_args();
-               $this->assertEquals(42, $uid);
-               $this->assertFalse($disableGroupAccessCheck);
-               $this->assertTrue($parent instanceof \TYPO3\CMS\Frontend\Page\PageRepository);
-       }
-
-       /////////////////////////////////////////
-       // Tests concerning getPathFromRootline
-       /////////////////////////////////////////
-       /**
-        * @test
-        */
-       public function getPathFromRootLineForEmptyRootLineReturnsEmptyString() {
-               $this->assertEquals('', $this->pageSelectObject->getPathFromRootline(array()));
-       }
-
-       ///////////////////////////////
-       // Tests concerning getExtURL
-       ///////////////////////////////
-       /**
-        * @test
-        */
-       public function getExtUrlForDokType3AndUrlType1AddsHttpSchemeToUrl() {
-               $this->assertEquals('http://www.example.com', $this->pageSelectObject->getExtURL(array(
-                       'doktype' => \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_LINK,
-                       'urltype' => 1,
-                       'url' => 'www.example.com'
-               )));
-       }
-
-       /**
-        * @test
-        */
-       public function getExtUrlForDokType3AndUrlType0PrependsSiteUrl() {
-               $this->assertEquals(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . 'hello/world/', $this->pageSelectObject->getExtURL(array(
-                       'doktype' => \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_LINK,
-                       'urltype' => 0,
-                       'url' => 'hello/world/'
-               )));
-       }
-
-}
-
-?>
\ No newline at end of file
diff --git a/tests/Unit/t3lib/file/BaseTestCase.php b/tests/Unit/t3lib/file/BaseTestCase.php
deleted file mode 100644 (file)
index 577d85b..0000000
+++ /dev/null
@@ -1,168 +0,0 @@
-<?php
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2011 Andreas Wolf <andreas.wolf@ikt-werk.de>
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *  A copy is found in the textfile GPL.txt and important notices to the license
- *  from the author is found in LICENSE.txt distributed with these scripts.
- *
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-/**
- * Basic test case for the t3lib_file tests
- *
- * @author Andreas Wolf <andreas.wolf@ikt-werk.de>
- * @package TYPO3
- * @subpackage t3lib
- */
-abstract class t3lib_file_BaseTestCase extends Tx_Phpunit_TestCase {
-
-       protected $basedir = 'basedir';
-
-       protected $mountDir;
-
-       protected $vfsContents = array();
-
-       public function setUp() {
-               $this->mountDir = uniqid('mount-');
-               $this->basedir = uniqid('base-');
-               vfsStream::setup($this->basedir);
-               // Add an entry for the mount directory to the VFS contents
-               $this->vfsContents = array($this->mountDir => array());
-       }
-
-       protected function getMountRootUrl() {
-               return $this->getUrlInMount('');
-       }
-
-       protected function mergeToVfsContents($contents) {
-               $this->vfsContents = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($this->vfsContents, $contents);
-       }
-
-       protected function initializeVfs() {
-               if (is_callable('vfsStream::create') === FALSE) {
-                       $this->markTestSkipped('vfsStream::create() does not exist');
-               }
-               vfsStream::create($this->vfsContents);
-       }
-
-       /**
-        * Adds the given directory structure to the mount folder in the VFS. Existing files will be overwritten!
-        *
-        * @param array $dirStructure
-        * @return void
-        */
-       protected function addToMount(array $dirStructure) {
-               $this->mergeToVfsContents(array($this->mountDir => $dirStructure));
-       }
-
-       /**
-        * Returns the URL for a path inside the mount directory
-        *
-        * @param $path
-        * @return string
-        */
-       protected function getUrlInMount($path) {
-               return vfsStream::url(((($this->basedir . '/') . $this->mountDir) . '/') . ltrim($path, '/'));
-       }
-
-       /**
-        * Adds the given directory structure to the VFS. Existing files will be overwritten!
-        *
-        * @param array $dirStructure
-        * @return void
-        */
-       protected function addToVfs(array $dirStructure) {
-               $this->mergeToVfsContents($dirStructure);
-       }
-
-       /**
-        * Returns the URL for a path inside the VFS
-        *
-        * @param $path
-        * @return string
-        */
-       protected function getUrl($path) {
-               return vfsStream::url(($this->basedir . '/') . ltrim($path, '/'));
-       }
-
-       /**
-        * Creates a file or folder mock. This should not be called directly, but only through getSimple{File,Folder}Mock()
-        *
-        * @param $type
-        * @param $identifier
-        * @param $mockedMethods
-        * @return \TYPO3\CMS\Core\Resource\File|\TYPO3\CMS\Core\Resource\Folder
-        */
-       protected function _createFileFolderMock($type, $identifier, $mockedMethods) {
-               if (!empty($mockedMethods)) {
-                       if (!in_array('getIdentifier', $mockedMethods)) {
-                               $mockedMethods[] = 'getIdentifier';
-                       }
-                       if (!in_array('getName', $mockedMethods)) {
-                               $mockedMethods[] = 'getName';
-                       }
-               }
-               $mock = $this->getMock($type, $mockedMethods, array(), '', FALSE);
-               $mock->expects($this->any())->method('getIdentifier')->will($this->returnValue($identifier));
-               $mock->expects($this->any())->method('getName')->will($this->returnValue(basename($identifier)));
-               return $mock;
-       }
-
-       /**
-        * Returns a simple mock of a file object that just knows its identifier
-        *
-        * @param string $identifier
-        * @param array $mockedMethods the methods to mock
-        * @return \TYPO3\CMS\Core\Resource\File
-        */
-       protected function getSimpleFileMock($identifier, $mockedMethods = array()) {
-               return $this->_createFileFolderMock('TYPO3\\CMS\\Core\\Resource\\File', $identifier, $mockedMethods);
-       }
-
-       /**
-        * Returns a simple mock of a file object that just knows its identifier
-        *
-        * @param string $identifier
-        * @param array $mockedMethods the methods to mock
-        * @return \TYPO3\CMS\Core\Resource\Folder
-        */
-       protected function getSimpleFolderMock($identifier, $mockedMethods = array()) {
-               return $this->_createFileFolderMock('TYPO3\\CMS\\Core\\Resource\\Folder', $identifier, $mockedMethods);
-       }
-
-       /**
-        * Returns a mock of a folder object with subfolders and files.
-        *
-        * @param $identifier
-        * @param array $mockedMethods Methods to mock, in addition to getFiles and getSubfolders
-        * @param \TYPO3\CMS\Core\Resource\Folder[] $subfolders
-        * @param \TYPO3\CMS\Core\Resource\File[] $files
-        * @return \TYPO3\CMS\Core\Resource\File|\TYPO3\CMS\Core\Resource\Folder
-        */
-       protected function getFolderMock($identifier, $mockedMethods = array(), $subfolders = array(), $files = array()) {
-               $folder = $this->_createFileFolderMock('TYPO3\\CMS\\Core\\Resource\\Folder', $identifier, array_merge($mockedMethods, array('getFiles', 'getSubfolders')));
-               $folder->expects($this->any())->method('getSubfolders')->will($this->returnValue($subfolders));
-               $folder->expects($this->any())->method('getFiles')->will($this->returnValue($files));
-               return $folder;
-       }
-
-}
-
-?>
\ No newline at end of file
diff --git a/tests/Unit/t3lib/file/Driver/AbstractDriverTest.php b/tests/Unit/t3lib/file/Driver/AbstractDriverTest.php
deleted file mode 100644 (file)
index 020b1b1..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-<?php
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2011-2012 Andreas Wolf <andreas.wolf@ikt-werk.de>
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *  A copy is found in the textfile GPL.txt and important notices to the license
- *  from the author is found in LICENSE.txt distributed with these scripts.
- *
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-
-require_once dirname(__FILE__) . '/../BaseTestCase.php';
-
-/**
- * Test case for the abstract driver.
- *
- * @author Andreas Wolf <andreas.wolf@ikt-werk.de>
- * @package TYPO3
- * @subpackage t3lib
- */
-class t3lib_file_Driver_AbstractDriverTest extends t3lib_file_BaseTestCase {
-
-       /**
-        * @var \TYPO3\CMS\Core\Resource\Driver\AbstractDriver
-        */
-       protected $fixture;
-
-       /**
-        * @return \TYPO3\CMS\Core\Resource\Driver\AbstractDriver
-        */
-       protected function createDriverFixture() {
-               return $this->getMockForAbstractClass('TYPO3\\CMS\\Core\\Resource\\Driver\\AbstractDriver', array(), '', FALSE);
-       }
-
-       public function filenameValidationDataProvider() {
-               return array(
-                       'all-lowercase filename with extension' => array(
-                               'testfile.txt',
-                               TRUE
-                       ),
-                       'regular filename with mixed case and extension' => array(
-                               'someFilename.jpg',
-                               TRUE
-                       ),
-                       'filename with german umlauts' => array(
-                               'anÜmläütTestfile.jpg',
-                               TRUE
-                       ),
-                       'filename with double extension' => array(
-                               'someCompressedFile.tar.gz',
-                               TRUE
-                       ),
-                       'filename with dash' => array(
-                               'foo-bar',
-                               TRUE
-                       ),
-                       'filename with number' => array(
-                               'some23Number',
-                               TRUE
-                       ),
-                       'filename with whitespace' => array(
-                               'some whitespace',
-                               TRUE
-                       ),
-                       'filename with tab' => array(
-                               ('some' . TAB) . 'tag',
-                               TRUE
-                       ),
-                       'filename with carriage return' => array(
-                               ('some' . CR) . 'CarriageReturn',
-                               FALSE
-                       ),
-                       'filename with linefeed' => array(
-                               ('some' . LF) . 'Linefeed',
-                               FALSE
-                       ),
-                       'filename with leading slash' => array(
-                               '/invalidAsFilename',
-                               FALSE
-                       ),
-                       'filename with null character' => array(
-                               ('someFile' . chr(0)) . 'name',
-                               FALSE
-                       )
-               );
-       }
-
-       /**
-        * @test
-        * @dataProvider filenameValidationDataProvider
-        */
-       public function filenamesAreCorrectlyValidated($filename, $expectedResult) {
-               $fixture = $this->createDriverFixture(array());
-               $result = $fixture->isValidFilename($filename);
-               $this->assertEquals($expectedResult, $result);
-       }
-
-       /**
-        * @test
-        */
-       public function getFolderCorrectlySetsFolderName() {
-               $identifier = '/someFolder/someSubfolder/';
-               $fixture = $this->createDriverFixture(array());
-               $fixture->setStorage($this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE));
-               $mockedFactory = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceFactory');
-               $mockedFactory->expects($this->once())->method('createFolderObject')->with($this->anything(), $this->anything(), 'someSubfolder');
-               \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Resource\\ResourceFactory', $mockedFactory);
-               $fixture->getFolder($identifier);
-       }
-
-}
-
-?>
\ No newline at end of file
diff --git a/tests/Unit/t3lib/file/Driver/DriverRegistryTest.php b/tests/Unit/t3lib/file/Driver/DriverRegistryTest.php
deleted file mode 100644 (file)
index 51d2e22..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-<?php
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2011 Andreas Wolf <andreas.wolf@ikt-werk.de>
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *  A copy is found in the textfile GPL.txt and important notices to the license
- *  from the author is found in LICENSE.txt distributed with these scripts.
- *
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-/**
- * Testcase for the FAL driver registry.
- *
- * @author Andreas Wolf <andreas.wolf@ikt-werk.de>
- * @package TYPO3
- * @subpackage t3lib
- */
-class t3lib_file_Driver_DriverRegistryTest extends Tx_Phpunit_TestCase {
-
-       /**
-        * @var boolean Enable backup of global and system variables
-        */
-       protected $backupGlobals = TRUE;
-
-       /**
-        * Exclude TYPO3_DB from backup/ restore of $GLOBALS
-        * because resource types cannot be handled during serializing
-        *
-        * @var array
-        */
-       protected $backupGlobalsBlacklist = array('TYPO3_DB');
-
-       /**
-        * @var \TYPO3\CMS\Core\Resource\Driver\DriverRegistry
-        */
-       private $fixture;
-
-       public function setUp() {
-               $this->initializeFixture();
-       }
-
-       protected function initializeFixture() {
-               $this->fixture = new \TYPO3\CMS\Core\Resource\Driver\DriverRegistry();
-       }
-
-       /**
-        * @test
-        */
-       public function registeredDriverClassesCanBeRetrieved() {
-               $className = $this->getMockClass('TYPO3\\CMS\\Core\\Resource\\Driver\\AbstractDriver');
-               $this->fixture->registerDriverClass($className, 'foobar');
-               $returnedClassName = $this->fixture->getDriverClass('foobar');
-               $this->assertEquals($className, $returnedClassName);
-       }
-
-       /**
-        * @test
-        */
-       public function registerDriverClassThrowsExceptionIfClassDoesNotExist() {
-               $this->setExpectedException('InvalidArgumentException', '', 1314979197);
-               $this->fixture->registerDriverClass(uniqid());
-       }
-
-       /**
-        * @test
-        */
-       public function registerDriverClassThrowsExceptionIfShortnameIsAlreadyTaken() {
-               $this->setExpectedException('InvalidArgumentException', '', 1314979451);
-               $className = $this->getMockClass('TYPO3\\CMS\\Core\\Resource\\Driver\\AbstractDriver');
-               $this->fixture->registerDriverClass($className, 'foobar');
-               $this->fixture->registerDriverClass($className, 'foobar');
-       }
-
-       /**
-        * @test
-        */
-       public function getDriverClassThrowsExceptionIfClassIsNotRegistered() {
-               $this->setExpectedException('InvalidArgumentException', '', 1314085990);
-               $this->fixture->getDriverClass(uniqid());
-       }
-
-       /**
-        * @test
-        */
-       public function getDriverClassAcceptsClassNameIfClassIsRegistered() {
-               $className = $this->getMockClass('TYPO3\\CMS\\Core\\Resource\\Driver\\AbstractDriver');
-               $this->fixture->registerDriverClass($className, 'foobar');
-               $this->assertEquals($className, $this->fixture->getDriverClass($className));
-       }
-
-       /**
-        * @test
-        */
-       public function driverRegistryIsInitializedWithPreconfiguredDrivers() {
-               $className = $this->getMockClass('TYPO3\\CMS\\Core\\Resource\\Driver\\AbstractDriver');
-               $shortName = uniqid();
-               $GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['registeredDrivers'] = array(
-                       $shortName => array(
-                               'class' => $className
-                       )
-               );
-               $this->initializeFixture();
-               $this->assertEquals($className, $this->fixture->getDriverClass($shortName));
-       }
-
-}
-
-?>
\ No newline at end of file
diff --git a/tests/Unit/t3lib/file/Driver/Fixtures/Dummy.html b/tests/Unit/t3lib/file/Driver/Fixtures/Dummy.html
deleted file mode 100644 (file)
index e5825e8..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<html>
-       <head>
-       </head>
-       <body>
-       </body>
-</html>
\ No newline at end of file
diff --git a/tests/Unit/t3lib/file/Driver/Fixtures/LocalDriverFilenameFilter.php b/tests/Unit/t3lib/file/Driver/Fixtures/LocalDriverFilenameFilter.php
deleted file mode 100644 (file)
index c9f2b3b..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2012 Andreas Wolf <andreas.wolf@ikt-werk.de>
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *  A copy is found in the textfile GPL.txt and important notices to the license
- *  from the author is found in LICENSE.txt distributed with these scripts.
- *
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-/**
- * Fixture class for the filename filters in the local driver.
- */
-class t3lib_file_Tests_Driver_Fixtures_LocalDriverFilenameFilter {
-
-       /**
-        * @param string $itemName
-        * @param string $itemIdentifier
-        * @param string $parentIdentifier
-        * @param \TYPO3\CMS\Core\Resource\Driver\AbstractDriver $driverInstance
-        * @return boolean|integer
-        */
-       static public function filterFilename($itemName, $itemIdentifier, $parentIdentifier, array $additionalInformation, \TYPO3\CMS\Core\Resource\Driver\AbstractDriver $driverInstance) {
-               if ($itemName == 'fileA' || $itemName == 'folderA/') {
-                       return -1;
-               } else {
-                       return TRUE;
-               }
-       }
-
-}
-
-?>
\ No newline at end of file
diff --git a/tests/Unit/t3lib/file/Driver/LocalDriverTest.php b/tests/Unit/t3lib/file/Driver/LocalDriverTest.php
deleted file mode 100644 (file)
index 181dfd9..0000000
+++ /dev/null
@@ -1,1527 +0,0 @@
-<?php
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2011 Andreas Wolf <andreas.wolf@ikt-werk.de>
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *  A copy is found in the textfile GPL.txt and important notices to the license
- *  from the author is found in LICENSE.txt distributed with these scripts.
- *
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-
-require_once 'vfsStream/vfsStream.php';
-require_once dirname(dirname(__FILE__)) . '/BaseTestCase.php';
-require_once dirname(__FILE__) . '/Fixtures/LocalDriverFilenameFilter.php';
-
-/**
- * Testcase for the local storage driver class of the TYPO3 VFS
- *
- * @package TYPO3
- * @subpackage t3lib
- * @author Andreas Wolf <andreas.wolf@ikt-werk.de>
- */
-class t3lib_file_Driver_LocalDriverTest extends t3lib_file_BaseTestCase {
-
-       static private $testDirs = array();
-
-       public function setUp() {
-               parent::setUp();
-               // use a mocked file repository to avoid updating the index when doing property update tests
-               $mockedRepository = $this->getMock('TYPO3\\CMS\\Core\\Resource\\FileRepository');
-               \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Resource\\FileRepository', $mockedRepository);
-       }
-
-       public function tearDown() {
-               \TYPO3\CMS\Core\Utility\GeneralUtility::purgeInstances();
-               parent::tearDown();
-       }
-
-       static public function tearDownAfterClass() {
-               foreach (self::$testDirs as $dir) {
-                       \TYPO3\CMS\Core\Utility\GeneralUtility::rmdir($dir, TRUE);
-               }
-       }
-
-       /**
-        * Creates a "real" directory for doing tests. This is neccessary because some file system properties (e.g. permissions)
-        * cannot be reflected by vfsStream, and some methods (like touch()) don't work there either.
-        *
-        * Created directories are automatically destroyed by the tearDownAfterClass() method.
-        *
-        * @return string
-        */
-       protected function createRealTestdir() {
-               $basedir = PATH_site . 'typo3temp/' . uniqid('fal-test-');
-               mkdir($basedir);
-               self::$testDirs[] = $basedir;
-               return $basedir;
-       }
-
-       /**
-        * Create a "real" directory together with a driverFixture configured
-        * for this directory.
-        *
-        * @return array With path to base directory and driver fixture
-        */
-       protected function prepareRealTestEnvironment() {
-               $basedir = $this->createRealTestdir();
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $basedir
-               ));
-               return array($basedir, $fixture);
-       }
-
-       /**
-        * Creates a driver fixture object, optionally using a given mount object.
-        *
-        * IMPORTANT: Call this only after setting up the virtual file system (with the addTo* methods)!
-        *
-        * @param $driverConfiguration
-        * @param \TYPO3\CMS\Core\Resource\ResourceStorage $storageObject
-        * @param array $mockedDriverMethods
-        * @return \TYPO3\CMS\Core\Resource\Driver\LocalDriver
-        */
-       protected function createDriverFixture($driverConfiguration, \TYPO3\CMS\Core\Resource\ResourceStorage $storageObject = NULL, $mockedDriverMethods = array()) {
-               $this->initializeVfs();
-               if ($storageObject == NULL) {
-                       $storageObject = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
-               }
-               if (count($mockedDriverMethods) == 0) {
-                       $driver = new \TYPO3\CMS\Core\Resource\Driver\LocalDriver($driverConfiguration);
-               } else {
-                       $driver = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Driver\\LocalDriver', $mockedDriverMethods, array($driverConfiguration));
-               }
-               $storageObject->setDriver($driver);
-               $driver->setStorage($storageObject);
-               $driver->processConfiguration();
-               $driver->initialize();
-               return $driver;
-       }
-
-       /**
-        * @test
-        */
-       public function rootLevelFolderIsCreatedWithCorrectArguments() {
-               $mockedMount = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
-               $fixture = $this->createDriverFixture(array(), $mockedMount);
-               $mockedFactory = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceFactory');
-               $mockedFactory->expects($this->once())->method('createFolderObject')->with($this->equalTo($mockedMount), $this->equalTo('/'), $this->equalTo(''));
-               \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Resource\\ResourceFactory', $mockedFactory);
-               $fixture->getRootLevelFolder();
-               \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Resource\\ResourceFactory', new \TYPO3\CMS\Core\Resource\ResourceFactory());
-       }
-
-       /**
-        * @test
-        */
-       public function getDefaultFolderReturnsFolderForTemporaryPath() {
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               $folder = $fixture->getDefaultFolder();
-               $this->assertStringEndsWith('_temp_/', $folder->getIdentifier());
-       }
-
-       /**
-        * @test
-        */
-       public function defaultLevelFolderFolderIsCreatedIfItDoesntExist() {
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               $fixture->getDefaultFolder();
-               $this->assertFileExists($this->getUrlInMount('/_temp_/'));
-       }
-
-       /**
-        * @test
-        */
-       public function getFolderInFolderReturnsCorrectFolderObject() {
-               $this->addToMount(array(
-                       'someDir' => array(
-                               'someSubdir' => array()
-                       )
-               ));
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               $parentFolder = $fixture->getFolder('/someDir');
-               $folder = $fixture->getFolderInFolder('someSubdir', $parentFolder);
-               $this->assertEquals('/someDir/someSubdir/', $folder->getIdentifier());
-       }
-
-       /**
-        * @test
-        */
-       public function createFolderCreatesFolderOnDisk() {
-               $this->addToMount(array('some' => array('folder' => array())));
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               $mockedFolder = $this->getSimpleFolderMock('/some/folder/');
-               $fixture->createFolder('path', $mockedFolder);
-               $this->assertFileExists($this->getUrlInMount('/some/folder/'));
-               $this->assertFileExists($this->getUrlInMount('/some/folder/path'));
-       }
-
-       /**
-        * @test
-        */
-       public function createFolderReturnsFolderObject() {
-               $this->addToMount(array('some' => array('folder' => array())));
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               $mockedFolder = $this->getSimpleFolderMock('/some/folder/');
-               $createdFolder = $fixture->createFolder('path', $mockedFolder);
-               $this->assertEquals('/some/folder/path/', $createdFolder->getIdentifier());
-       }
-
-       public function createFolderSanitizesFolderNameBeforeCreationDataProvider() {
-               return array(
-                       'folder name with NULL character' => array(
-                               'some' . chr(0) . 'Folder',
-                               'some_Folder'
-                       ),
-                       'folder name with directory part' => array(
-                               '../someFolder',
-                               '.._someFolder'
-                       )
-               );
-       }
-
-       /**
-        * @test
-        * @dataProvider createFolderSanitizesFolderNameBeforeCreationDataProvider
-        */
-       public function createFolderSanitizesFolderNameBeforeCreation($newFolderName, $expectedFolderName) {
-               $this->addToMount(array('some' => array('folder' => array())));
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               $mockedFolder = $this->getSimpleFolderMock('/some/folder/');
-               $fixture->createFolder($newFolderName, $mockedFolder);
-               $this->assertFileExists($this->getUrlInMount('/some/folder/' . $expectedFolderName));
-       }
-
-       /**
-        * @test
-        */
-       public function driverConfigVerificationFailsIfConfiguredBasePathDoesNotExist() {
-               $this->setExpectedException('TYPO3\\CMS\\Core\\Resource\\Exception\\InvalidConfigurationException', '', 1299233097);
-               $driverConfiguration = array(
-                       'basePath' => vfsStream::url($this->basedir . 'doesntexist/')
-               );
-               $this->assertFalse(file_exists($driverConfiguration['basePath']));
-               \TYPO3\CMS\Core\Resource\Driver\LocalDriver::verifyConfiguration($driverConfiguration);
-       }
-
-       /**
-        * @test
-        */
-       public function basePathIsNormalizedWithTrailingSlash() {
-               $driverConfiguration = array(
-                       'basePath' => $this->getMountRootUrl()
-               );
-               $fixture = $this->createDriverFixture($driverConfiguration);
-               $this->assertEquals('/', substr($fixture->getAbsoluteBasePath(), -1));
-       }
-
-       /**
-        * @test
-        */
-       public function noSecondSlashIsAddedIfBasePathAlreadyHasTrailingSlash() {
-               $driverConfiguration = array(
-                       'basePath' => $this->getMountRootUrl()
-               );
-               $fixture = $this->createDriverFixture($driverConfiguration);
-               $this->assertNotEquals('/', substr($fixture->getAbsoluteBasePath(), -2, 1));
-       }
-
-       /**
-        * @test
-        */
-       public function getAbsolutePathReturnsCorrectPath() {
-               $this->addToMount(array(
-                       'someFolder' => array(
-                               'file1.ext' => 'asdfg'
-                       )
-               ));
-               $mockedFile = $this->getSimpleFileMock('someFolder/file1.ext');
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               $path = $fixture->getAbsolutePath($mockedFile);
-               $this->assertTrue(file_exists($path));
-               $this->assertEquals($this->getUrlInMount('/someFolder/file1.ext'), $path);
-       }
-
-       /**
-        * @test
-        */
-       public function getLowLevelFileInfoReturnsCorrectFileSize() {
-               $contents = uniqid('foo');
-               $this->addToMount(array('file1.ext' => $contents));
-               $mockedFile = $this->getSimpleFileMock('file1.ext');
-               $fixture = $this->createDriverFixture(
-                       array('basePath' => $this->getMountRootUrl()),
-                       NULL,
-                               // Mocked because finfo() can not deal with vfs streams and throws warnings
-                       array('getMimeTypeOfFile')
-               );
-               $stat = $fixture->getLowLevelFileInfo($mockedFile);
-               $this->assertEquals(strlen($contents), $stat['size']);
-       }
-
-       /**
-        * @test
-        */
-       public function getLowLevelFileInfoReturnsCorrectFileCtime() {
-               $contents = uniqid('foo');
-               $this->addToMount(array('file1.ext' => $contents));
-               $mockedFile = $this->getSimpleFileMock('file1.ext');
-               $fixture = $this->createDriverFixture(
-                       array('basePath' => $this->getMountRootUrl()),
-                       NULL,
-                               // Mocked because finfo() can not deal with vfs streams and throws warnings
-                       array('getMimeTypeOfFile')
-               );
-               $path = $fixture->getAbsolutePath($mockedFile);
-               $stat = $fixture->getLowLevelFileInfo($mockedFile);
-               $this->assertEquals(filectime($path), $stat['ctime']);
-       }
-
-       /**
-        * @test
-        */
-       public function getLowLevelFileInfoReturnsCorrectFileMtime() {
-               $contents = uniqid('foo');
-               $this->addToMount(array('file1.ext' => $contents));
-               $mockedFile = $this->getSimpleFileMock('file1.ext');
-               $fixture = $this->createDriverFixture(
-                       array('basePath' => $this->getMountRootUrl()),
-                       NULL,
-                               // Mocked because finfo() can not deal with vfs streams and throws warnings
-                       array('getMimeTypeOfFile')
-               );
-               $path = $fixture->getAbsolutePath($mockedFile);
-               $stat = $fixture->getLowLevelFileInfo($mockedFile);
-               $this->assertEquals(fileatime($path), $stat['mtime']);
-       }
-
-       /**
-        * @test
-        */
-       public function getLowLevelFileInfoReturnsCorrectFileAtime() {
-               $contents = uniqid('foo');
-               $this->addToMount(array('file1.ext' => $contents));
-               $mockedFile = $this->getSimpleFileMock('file1.ext');
-               $fixture = $this->createDriverFixture(
-                       array('basePath' => $this->getMountRootUrl()),
-                       NULL,
-                               // Mocked because finfo() can not deal with vfs streams and throws warnings
-                       array('getMimeTypeOfFile')
-               );
-               $path = $fixture->getAbsolutePath($mockedFile);
-               $stat = $fixture->getLowLevelFileInfo($mockedFile);
-               $this->assertEquals(filemtime($path), $stat['atime']);
-       }
-
-       /**
-        * @test
-        */
-       public function getLowLevelFileInfoReturnsCorrectFileMimeType() {
-               $baseDir = $this->createRealTestdir();
-               /** @var $driverFixture \TYPO3\CMS\Core\Resource\Driver\LocalDriver */
-               $driverFixture = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Driver\\LocalDriver', array('getAbsolutePath'), array());
-               $fileMock = $this->getMock('TYPO3\\CMS\\Core\\Resource\\FileInterface');
-               copy(__DIR__ . '/Fixtures/Dummy.html', $baseDir . '/Dummy.html');
-               $driverFixture->expects($this->once())->method('getAbsolutePath')->will($this->returnValue($baseDir . '/Dummy.html'));
-               $stats = $driverFixture->getLowLevelFileInfo($fileMock);
-               $this->assertEquals('text/html', $stats['mimetype']);
-       }
-
-       /**
-        * @test
-        */
-       public function addFileMovesFileToCorrectLocation() {
-               $mockedFolder = $this->getSimpleFolderMock('/targetFolder/');
-               $this->addToMount(array('targetFolder' => array()));
-               $this->addToVfs(array(
-                       'sourceFolder' => array(
-                               'file' => 'asdf'
-                       )
-               ));
-               $fixture = $this->createDriverFixture(
-                       array('basePath' => $this->getMountRootUrl()),
-                       NULL,
-                               // Mocked because finfo() can not deal with vfs streams and throws warnings
-                       array('getMimeTypeOfFile')
-               );
-               $this->assertTrue(file_exists($this->getUrl('sourceFolder/file')));
-               $fixture->addFile($this->getUrl('sourceFolder/file'), $mockedFolder, 'file');
-               $this->assertTrue(file_exists($this->getUrlInMount('/targetFolder/file')));
-       }
-
-       /**
-        * @test
-        */
-       public function addFileUsesFilenameIfGiven() {
-               $mockedFolder = $this->getSimpleFolderMock('/targetFolder/');
-               $this->addToMount(array('targetFolder' => array()));
-               $this->addToVfs(array(
-                       'sourceFolder' => array(
-                               'file' => 'asdf'
-                       )
-               ));
-               $fixture = $this->createDriverFixture(
-                       array('basePath' => $this->getMountRootUrl()),
-                       NULL,
-                               // Mocked because finfo() can not deal with vfs streams and throws warnings
-                       array('getMimeTypeOfFile')
-               );
-               $this->assertTrue(file_exists($this->getUrl('sourceFolder/file')));
-               $fixture->addFile($this->getUrl('sourceFolder/file'), $mockedFolder, 'targetFile');
-               $this->assertTrue(file_exists($this->getUrlInMount('/targetFolder/targetFile')));
-       }
-
-       /**
-        * @test
-        */
-       public function addFileFailsIfFileIsInDriverStorage() {
-               $mockedFolder = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Folder', array(), array(), '', FALSE);
-               $mockedFolder->expects($this->any())->method('getIdentifier')->will($this->returnValue('/targetFolder/'));
-               $this->setExpectedException('InvalidArgumentException', '', 1314778269);
-               $this->addToMount(array(
-                       'targetFolder' => array(
-                               'file' => 'asdf'
-                       )
-               ));
-               $storageObject = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
-               $storageObject->expects($this->any())->method('getUid')->will($this->returnValue('1'));
-               $fixture = $this->createDriverFixture(
-                       array('basePath' => $this->getMountRootUrl()),
-                       $storageObject
-               );
-               $fixture->addFile($this->getUrlInMount('/targetFolder/file'), $mockedFolder, 'file');
-       }
-
-       /**
-        * @test
-        */
-       public function addFileReturnsFileObject() {
-               $mockedFolder = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Folder', array(), array(), '', FALSE);
-               $mockedFolder->expects($this->any())->method('getIdentifier')->will($this->returnValue('/targetFolder/'));
-               $this->addToMount(array('targetFolder' => array()));
-               $this->addToVfs(array(
-                       'sourceFolder' => array(
-                               'file' => 'asdf'
-                       )
-               ));
-               $fixture = $this->createDriverFixture(
-                       array('basePath' => $this->getMountRootUrl()),
-                       NULL,
-                               // Mocked because finfo() can not deal with vfs streams and throws warnings
-                       array('getMimeTypeOfFile')
-               );
-               $this->assertTrue(file_exists($this->getUrl('sourceFolder/file')));
-               $fileObject = $fixture->addFile($this->getUrl('sourceFolder/file'), $mockedFolder, 'file');
-               $this->assertInstanceOf('TYPO3\\CMS\\Core\\Resource\\File', $fileObject);
-               $this->assertEquals('file', $fileObject->getName());
-               $this->assertEquals('/targetFolder/file', $fileObject->getIdentifier());
-       }
-
-       /**
-        * @test
-        */
-       public function addFileRawCreatesCopyOfFile() {
-               $this->addToMount(array('targetFolder' => array()));
-               $this->addToVfs(array(
-                       'sourceFolder' => array(
-                               'file' => 'asdf'
-                       )
-               ));
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               $this->assertTrue(file_exists($this->getUrl('sourceFolder/file')));
-               $fileIdentifier = $fixture->addFileRaw($this->getUrl('sourceFolder/file'), $this->getSimpleFolderMock('/targetFolder/'), 'somefile');
-               $this->assertTrue(file_exists($this->getUrl('sourceFolder/file')));
-               $this->assertTrue(file_exists($this->getUrlInMount('targetFolder/somefile')));
-               $this->assertEquals('/targetFolder/somefile', $fileIdentifier);
-       }
-
-       /**
-        * @test
-        */
-       public function deleteFileRawRemovesFile() {
-               $this->addToMount(array(
-                       'targetFolder' => array(
-                               'file' => 'asdjlkfa'
-                       )
-               ));
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               $this->assertTrue(file_exists($this->getUrlInMount('targetFolder/file')));
-               $fixture->deleteFileRaw('/targetFolder/file');
-               $this->assertFalse(file_exists($this->getUrlInMount('targetFolder/file')));
-       }
-
-       /**
-        * @test
-        */
-       public function replacingFileUpdatesMetadataInFileObject() {
-               $this->addToMount(array(
-                       'targetFolder' => array(
-                               'file' => 'asdjlkfa'
-                       )
-               ));
-               $this->addToVfs(array(
-                       'sourceFolder' => array(
-                               'file' => 'asjdalks'
-                       )
-               ));
-               $fixture = $this->createDriverFixture(
-                       array('basePath' => $this->getMountRootUrl()),
-                       NULL,
-                               // Mocked because finfo() can not deal with vfs streams and throws warnings
-                       array('getMimeTypeOfFile')
-               );
-               $mockedFile = $this->getSimpleFileMock('/targetFolder/file', array('updateProperties'));
-               $mockedFile->expects($this->once())->method('updateProperties');
-               $fixture->replaceFile($mockedFile, $this->getUrl('sourceFolder/file'));
-       }
-
-       /**
-        * @test
-        */
-       public function existenceChecksWorkForFilesAndFolders() {
-               $this->addToMount(array(
-                       'file' => 'asdf',
-                       'folder' => array()
-               ));
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               // Using slashes at the beginning of paths because they will be stored in the DB this way.
-               $this->assertTrue($fixture->fileExists('/file'));
-               $this->assertTrue($fixture->folderExists('/folder/'));
-               $this->assertFalse($fixture->fileExists('/nonexistingFile'));
-               $this->assertFalse($fixture->folderExists('/nonexistingFolder/'));
-       }
-
-       /**
-        * @test
-        */
-       public function existenceChecksInFolderWorkForFilesAndFolders() {
-               $mockedFolder = $this->getSimpleFolderMock('/subfolder/');
-               $this->addToMount(array(
-                       'subfolder' => array(
-                               'file' => 'asdf',
-                               'folder' => array()
-                       )
-               ));
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               $this->assertTrue($fixture->fileExistsInFolder('file', $mockedFolder));
-               $this->assertTrue($fixture->folderExistsInFolder('folder', $mockedFolder));
-               $this->assertFalse($fixture->fileExistsInFolder('nonexistingFile', $mockedFolder));
-               $this->assertFalse($fixture->folderExistsInFolder('nonexistingFolder', $mockedFolder));
-       }
-
-       /**
-        * @test
-        */
-       public function getPublicUrlReturnsCorrectUriForConfiguredBaseUri() {
-               $baseUri = 'http://example.org/foobar/' . uniqid();
-               $this->addToMount(array(
-                       'file.ext' => 'asdf',
-                       'subfolder' => array(
-                               'file2.ext' => 'asdf'
-                       )
-               ));
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl(),
-                       'baseUri' => $baseUri
-               ));
-               $mockedFile1 = $this->getMock('TYPO3\\CMS\\Core\\Resource\\File', array(), array(), '', FALSE);
-               $mockedFile1->expects($this->any())->method('getIdentifier')->will($this->returnValue('/file.ext'));
-               $mockedFile2 = $this->getMock('TYPO3\\CMS\\Core\\Resource\\File', array(), array(), '', FALSE);
-               $mockedFile2->expects($this->any())->method('getIdentifier')->will($this->returnValue('/subfolder/file2.ext'));
-               $this->assertEquals($baseUri . '/file.ext', $fixture->getPublicUrl($mockedFile1));
-               $this->assertEquals($baseUri . '/subfolder/file2.ext', $fixture->getPublicUrl($mockedFile2));
-       }
-
-       /**
-        * @test
-        */
-       public function fileContentsCanBeWrittenAndRead() {
-               $fileContents = 'asdf';
-               $this->addToMount(array(
-                       'file.ext' => $fileContents
-               ));
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               $mockedFile = $this->getMock('TYPO3\\CMS\\Core\\Resource\\File', array(), array(), '', FALSE);
-               $mockedFile->expects($this->any())->method('getIdentifier')->will($this->returnValue('/file.ext'));
-               $this->assertEquals($fileContents, $fixture->getFileContents($mockedFile), 'File contents could not be read');
-               $newFileContents = 'asdfgh';
-               $fixture->setFileContents($mockedFile, $newFileContents);
-               $this->assertEquals($newFileContents, $fixture->getFileContents($mockedFile), 'New file contents could not be read.');
-       }
-
-       /**
-        * @test
-        */
-       public function setFileContentsReturnsNumberOfBytesWrittenToFile() {
-               $fileContents = 'asdf';
-               $this->addToMount(array(
-                       'file.ext' => $fileContents
-               ));
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               $mockedFile = $this->getSimpleFileMock('/file.ext');
-               $newFileContents = 'asdfgh';
-               $bytesWritten = $fixture->setFileContents($mockedFile, $newFileContents);
-               $this->assertEquals(strlen($newFileContents), $bytesWritten);
-       }
-
-       /**
-        * @test
-        * @depends existenceChecksWorkForFilesAndFolders
-        * @return array The driver fixture, the mocked file
-        */
-       public function newFilesCanBeCreated() {
-               $this->addToMount(array(
-                       'someDir' => array()
-               ));
-               /** @var $fixture \TYPO3\CMS\Core\Resource\Driver\LocalDriver */
-               list($basedir, $fixture) = $this->prepareRealTestEnvironment();
-               mkdir($basedir . '/someDir');
-               $fixture->createFile('testfile.txt', $fixture->getFolder('someDir'));
-               $mockedFile = $this->getSimpleFileMock('/someDir/testfile.txt');
-               $this->assertTrue($fixture->fileExists('/someDir/testfile.txt'));
-               return array($fixture, $mockedFile);
-       }
-
-       /**
-        * @test
-        * @depends newFilesCanBeCreated
-        */
-       public function createdFilesAreEmpty(array $arguments) {
-               /** @var $fixture \TYPO3\CMS\Core\Resource\Driver\LocalDriver */
-               list($fixture, $mockedFile) = $arguments;
-               $fileData = $fixture->getFileContents($mockedFile);
-               $this->assertEquals(0, strlen($fileData));
-       }
-
-       /**********************************
-        * File and directory listing
-        **********************************/
-       /**
-        * @test
-        */
-       public function getFileReturnsCorrectIdentifier() {
-               $this->addToMount(array(
-                       'someDir' => array(
-                               'someFile' => 'asdfg'
-                       ),
-                       'someFileAtRootLevel' => 'foobar'
-               ));
-               $fixture = $this->createDriverFixture(
-                       array('basePath' => $this->getMountRootUrl()),
-                       NULL,
-                               // Mocked because finfo() can not deal with vfs streams and throws warnings
-                       array('getMimeTypeOfFile')
-               );
-               $subdirFileInfo = $fixture->getFileInfoByIdentifier('/someDir/someFile');
-               $this->assertEquals('/someDir/someFile', $subdirFileInfo['identifier']);
-               $rootFileInfo = $fixture->getFileInfoByIdentifier('/someFileAtRootLevel');
-               $this->assertEquals('/someFileAtRootLevel', $rootFileInfo['identifier']);
-       }
-
-       /**
-        * @test
-        */
-       public function getFileThrowsExceptionIfFileDoesNotExist() {
-               $this->setExpectedException('InvalidArgumentException', '', 1314516809);
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               $fixture->getFileInfoByIdentifier('/some/file/at/a/random/path');
-       }
-
-       /**
-        * @test
-        */
-       public function getFileListReturnsEmptyArrayForEmptyDirectory() {
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               $fileList = $fixture->getFileList('/');
-               $this->assertEmpty($fileList);
-       }
-
-       /**
-        * @test
-        */
-       public function getFileListReturnsAllFilesInDirectory() {
-               $dirStructure = array(
-                       'aDir' => array(),
-                       'file1' => 'asdfg',
-                       'file2' => 'fdsa'
-               );
-               $this->addToMount($dirStructure);
-               $fixture = $this->createDriverFixture(
-                       array('basePath' => $this->getMountRootUrl()),
-                       NULL,
-                               // Mocked because finfo() can not deal with vfs streams and throws warnings
-                       array('getMimeTypeOfFile')
-               );
-               $fileList = $fixture->getFileList('/');
-               $this->assertEquals(array('file1', 'file2'), array_keys($fileList));
-       }
-
-       /**
-        * @test
-        */
-       public function getFileListFailsIfDirectoryDoesNotExist() {
-               $this->setExpectedException('InvalidArgumentException', '', 1314349666);
-               $this->addToMount(array('somefile' => ''));
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               $fixture->getFileList('somedir/');
-       }
-
-       /**
-        * @test
-        */
-       public function getFileListCallsConfiguredCallbackFunctionWithGivenItemName() {
-               $dirStructure = array(
-                       'file2' => 'fdsa'
-               );
-               // register static callback to self
-               $callback = array(
-                       array(
-                               get_class($this),
-                               'callbackStaticTestFunction'
-                       )
-               );
-               $this->addToMount($dirStructure);
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               // the callback function will throw an exception used to check if it was called with correct $itemName
-               $this->setExpectedException('InvalidArgumentException', '$itemName', 1336159604);
-               $fixture->getFileList('/', 0, 0, $callback);
-       }
-
-       /**
-        * Static callback function used to test if the filter callbacks work
-        * As it is static we are using an exception to test if it is really called and works
-        *
-        * @static
-        * @throws \InvalidArgumentException
-        * @see getFileListCallsConfiguredCallbackFunction
-        */
-       static public function callbackStaticTestFunction() {
-               list($itemName) = func_get_args();
-               if ($itemName === 'file2') {
-                       throw new InvalidArgumentException('$itemName', 1336159604);
-               }
-       }
-
-       /**
-        * @test
-        */
-       public function getFileListFiltersItemsWithGivenFilterMethods() {
-               $dirStructure = array(
-                       'fileA' => 'asdfg',
-                       'fileB' => 'fdsa'
-               );
-               $this->addToMount($dirStructure);
-               $fixture = $this->createDriverFixture(
-                       array('basePath' => $this->getMountRootUrl()),
-                       NULL,
-                               // Mocked because finfo() can not deal with vfs streams and throws warnings
-                       array('getMimeTypeOfFile')
-               );
-               $filterCallbacks = array(
-                       array('t3lib_file_Tests_Driver_Fixtures_LocalDriverFilenameFilter', 'filterFilename')
-               );
-               $fileList = $fixture->getFileList('/', 0, 0, $filterCallbacks);
-               $this->assertNotContains('fileA', array_keys($fileList));
-       }
-
-       /**
-        * @test
-        */
-       public function getFolderListReturnsAllDirectoriesInDirectory() {
-               $dirStructure = array(
-                       'dir1' => array(),
-                       'dir2' => array(),
-                       'file' => 'asdfg'
-               );
-               $this->addToMount($dirStructure);
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               $fileList = $fixture->getFolderList('/');
-               $this->assertEquals(array('dir1', 'dir2'), array_keys($fileList));
-       }
-
-       /**
-        * @test
-        */
-       public function getFolderListDoesNotReturnHiddenFoldersByDefault() {
-               $dirStructure = array(
-                       '.someHiddenFile' => array(),
-                       'aDir' => array(),
-                       'file1' => ''
-               );
-               $this->addToMount($dirStructure);
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               $fileList = $fixture->getFolderList('/');
-               $this->assertEquals(array('aDir'), array_keys($fileList));
-       }
-
-       /**
-        * @test
-        */
-       public function getFolderListUsesCorrectPathForItems() {
-               $this->addToMount(array(
-                       'dir1' => array(
-                               'subdir1' => array()
-                       )
-               ));
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               $FolderList = $fixture->getFolderList('/');
-               $this->assertEquals('/dir1/', $FolderList['dir1']['identifier']);
-               $FolderList = $fixture->getFolderList('/dir1/');
-               $this->assertEquals('/dir1/subdir1/', $FolderList['subdir1']['identifier']);
-       }
-
-       /**
-        * Checks if the folder names . and .. are ignored when listing subdirectories
-        *
-        * @test
-        */
-       public function getFolderListLeavesOutNavigationalEntries() {
-               // we have to add .. and . manually, as these are not included in vfsStream directory listings (as opposed
-               // to normal file listings)
-               $this->addToMount(array(
-                       '..' => array(),
-                       '.' => array()
-               ));
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               $fileList = $fixture->getFolderList('/');
-               $this->assertEmpty($fileList);
-       }
-
-       /**
-        * @test
-        */
-       public function getFolderListFiltersItemsWithGivenFilterMethods() {
-               $dirStructure = array(
-                       'folderA' => array(),
-                       'folderB' => array()
-               );
-               $this->addToMount($dirStructure);
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               $filterCallbacks = array(
-                       array('t3lib_file_Tests_Driver_Fixtures_LocalDriverFilenameFilter', 'filterFilename')
-               );
-               $folderList = $fixture->getFolderList('/', 0, 0, $filterCallbacks);
-               $this->assertNotContains('folderA', array_keys($folderList));
-       }
-
-       /**
-        * @test
-        */
-       public function getFolderListFailsIfDirectoryDoesNotExist() {
-               $this->setExpectedException('InvalidArgumentException', '', 1314349666);
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               vfsStream::create(array($this->basedir => array('somefile' => '')));
-               $fixture->getFolderList('somedir/');
-       }
-
-       /**
-        * @test
-        */
-       public function hashReturnsCorrectHashes() {
-               $contents = '68b329da9893e34099c7d8ad5cb9c940';
-               $expectedMd5Hash = '8c67dbaf0ba22f2e7fbc26413b86051b';
-               $expectedSha1Hash = 'a60cd808ba7a0bcfa37fa7f3fb5998e1b8dbcd9d';
-               $mockedFile = $this->getSimpleFileMock('/hashFile');
-               $this->addToMount(array('hashFile' => $contents));
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               $this->assertEquals($expectedSha1Hash, $fixture->hash($mockedFile, 'sha1'));
-               $this->assertEquals($expectedMd5Hash, $fixture->hash($mockedFile, 'md5'));
-       }
-
-       /**
-        * @test
-        */
-       public function hashingWithUnsupportedAlgorithmFails() {
-               $this->setExpectedException('InvalidArgumentException', '', 1304964032);
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               $fixture->hash($this->getSimpleFileMock('/hashFile'), uniqid());
-       }
-
-       /**
-        * @test
-        * @covers TYPO3\CMS\Core\Resource\Driver\LocalDriver::getFileForLocalProcessing
-        */
-       public function getFileForLocalProcessingCreatesCopyOfFileByDefault() {
-               $fileContents = 'asdfgh';
-               $this->addToMount(array(
-                       'someDir' => array(
-                               'someFile' => $fileContents
-                       )
-               ));
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ), NULL, array('copyFileToTemporaryPath'));
-               $mockedFile = $this->getSimpleFileMock('/someDir/someFile');
-               // TODO add parameter expectation for $mockedFile as soon as PHPUnit supports object identity matching in parameter expectations
-               $fixture->expects($this->once())->method('copyFileToTemporaryPath');
-               $fixture->getFileForLocalProcessing($mockedFile);
-       }
-
-       /**
-        * @test
-        */
-       public function getFileForLocalProcessingReturnsOriginalFilepathForReadonlyAccess() {
-               $fileContents = 'asdfgh';
-               $this->addToMount(array(
-                       'someDir' => array(
-                               'someFile' => $fileContents
-                       )
-               ));
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               $mockedFile = $this->getSimpleFileMock('/someDir/someFile');
-               $filePath = $fixture->getFileForLocalProcessing($mockedFile, FALSE);
-               $this->assertEquals($filePath, $this->getMountRootUrl() . 'someDir/someFile');
-       }
-
-       /**
-        * @test
-        */
-       public function filesCanBeCopiedToATemporaryPath() {
-               $fileContents = 'asdfgh';
-               $this->addToMount(array(
-                       'someDir' => array(
-                               'someFile' => $fileContents
-                       )
-               ));
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               $mockedFile = $this->getSimpleFileMock('/someDir/someFile');
-               $filePath = $fixture->copyFileToTemporaryPath($mockedFile);
-               $this->assertContains('/typo3temp/', $filePath);
-               $this->assertEquals($fileContents, file_get_contents($filePath));
-       }
-
-       /**
-        * @test
-        */
-       public function permissionsAreCorrectlyRetrievedForAllowedFile() {
-               /** @var $fixture \TYPO3\CMS\Core\Resource\Driver\LocalDriver */
-               list($basedir, $fixture) = $this->prepareRealTestEnvironment();
-               touch($basedir . '/someFile');
-               chmod($basedir . '/someFile', 448);
-               clearstatcache();
-               $this->assertEquals(array('r' => TRUE, 'w' => TRUE), $fixture->getFilePermissions($this->getSimpleFileMock('/someFile')));
-       }
-
-       /**
-        * @test
-        */
-       public function permissionsAreCorrectlyRetrievedForForbiddenFile() {
-               if (function_exists('posix_getegid') && posix_getegid() === 0) {
-                       $this->markTestSkipped('Test skipped if run on linux as root');
-               }
-               /** @var $fixture \TYPO3\CMS\Core\Resource\Driver\LocalDriver */
-               list($basedir, $fixture) = $this->prepareRealTestEnvironment();
-               touch($basedir . '/someForbiddenFile');
-               chmod($basedir . '/someForbiddenFile', 0);
-               clearstatcache();
-               $this->assertEquals(array('r' => FALSE, 'w' => FALSE), $fixture->getFilePermissions($this->getSimpleFileMock('/someForbiddenFile')));
-       }
-
-       /**
-        * @test
-        */
-       public function permissionsAreCorrectlyRetrievedForAllowedFolder() {
-               /** @var $fixture \TYPO3\CMS\Core\Resource\Driver\LocalDriver */
-               list($basedir, $fixture) = $this->prepareRealTestEnvironment();
-               mkdir($basedir . '/someFolder');
-               chmod($basedir . '/someFolder', 448);
-               clearstatcache();
-               $this->assertEquals(array('r' => TRUE, 'w' => TRUE), $fixture->getFolderPermissions($this->getSimpleFolderMock('/someFolder')));
-       }
-
-       /**
-        * @test
-        */
-       public function permissionsAreCorrectlyRetrievedForForbiddenFolder() {
-               if (function_exists('posix_getegid') && posix_getegid() === 0) {
-                       $this->markTestSkipped('Test skipped if run on linux as root');
-               }
-               /** @var $fixture \TYPO3\CMS\Core\Resource\Driver\LocalDriver */
-               list($basedir, $fixture) = $this->prepareRealTestEnvironment();
-               mkdir($basedir . '/someForbiddenFolder');
-               chmod($basedir . '/someForbiddenFolder', 0);
-               clearstatcache();
-               $this->assertEquals(array('r' => FALSE, 'w' => FALSE), $fixture->getFolderPermissions($this->getSimpleFolderMock('/someForbiddenFolder')));
-       }
-
-       /**
-        * Dataprovider for getFilePermissionsReturnsCorrectPermissionsForFilesNotOwnedByCurrentUser test
-        *
-        * @return array group, filemode and expected result
-        */
-       public function getFilePermissionsReturnsCorrectPermissionsForFilesNotOwnedByCurrentUser_dataProvider() {
-               $data = array();
-               // On some OS, the posix_* functions do not exits
-               if (function_exists('posix_getgid')) {
-                       $data = array(
-                               'current group, readable/writable' => array(
-                                       posix_getgid(),
-                                       48,
-                                       array('r' => TRUE, 'w' => TRUE)
-                               ),
-                               'current group, readable/not writable' => array(
-                                       posix_getgid(),
-                                       32,
-                                       array('r' => TRUE, 'w' => FALSE)
-                               ),
-                               'current group, not readable/not writable' => array(
-                                       posix_getgid(),
-                                       0,
-                                       array('r' => FALSE, 'w' => FALSE)
-                               )
-                       );
-               }
-               $data = array_merge_recursive($data, array(
-                       'arbitrary group, readable/writable' => array(
-                               vfsStream::GROUP_USER_1,
-                               6,
-                               array('r' => TRUE, 'w' => TRUE)
-                       ),
-                       'arbitrary group, readable/not writable' => array(
-                               vfsStream::GROUP_USER_1,
-                               436,
-                               array('r' => TRUE, 'w' => FALSE)
-                       ),
-                       'arbitrary group, not readable/not writable' => array(
-                               vfsStream::GROUP_USER_1,
-                               432,
-                               array('r' => FALSE, 'w' => FALSE)
-                       )
-               ));
-               return $data;
-       }
-
-       /**
-        * @test
-        * @dataProvider getFilePermissionsReturnsCorrectPermissionsForFilesNotOwnedByCurrentUser_dataProvider
-        */
-       public function getFilePermissionsReturnsCorrectPermissionsForFilesNotOwnedByCurrentUser($group, $permissions, $expectedResult) {
-               $this->addToMount(array(
-                       'testfile' => 'asdfg'
-               ));
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               /** @var $fileObject vfsStreamContent */
-               $fileObject = vfsStreamWrapper::getRoot()->getChild($this->mountDir)->getChild('testfile');
-               // just use an "arbitrary" user here - it is only important that
-               $fileObject->chown(vfsStream::OWNER_USER_1);
-               $fileObject->chgrp($group);
-               $fileObject->chmod($permissions);
-               $this->assertEquals($expectedResult, $fixture->getFilePermissions($this->getSimpleFileMock('/testfile')));
-       }
-
-       /**
-        * @test
-        */
-       public function isWithinRecognizesFilesWithinFolderAndInOtherFolders() {
-               $mockedStorage = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
-               $mockedFolder = new \TYPO3\CMS\Core\Resource\Folder($mockedStorage, '/someFolder/', 'someFolder');
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ), $mockedStorage);
-               $this->assertTrue($fixture->isWithin($mockedFolder, '/someFolder/test.jpg'));
-               $this->assertTrue($fixture->isWithin($mockedFolder, '/someFolder/subFolder/test.jpg'));
-               $this->assertFalse($fixture->isWithin($mockedFolder, '/someFolderWithALongName/test.jpg'));
-       }
-
-       /**
-        * @test
-        */
-       public function isWithinAcceptsFileAndFolderObjectsAsContent() {
-               $mockedStorage = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
-               $mockedFolder = new \TYPO3\CMS\Core\Resource\Folder($mockedStorage, '/someFolder/', 'someFolder');
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ), $mockedStorage);
-               $mockedSubfolder = $this->getSimpleFolderMock('/someFolder/subfolder/');
-               $mockedFile = $this->getSimpleFileMock('/someFolder/test.jpg');
-               $this->assertTrue($fixture->isWithin($mockedFolder, $mockedFile));
-               $this->assertTrue($fixture->isWithin($mockedFolder, $mockedSubfolder));
-       }
-
-       /**
-        * @test
-        */
-       public function isWithinAlwaysReturnsFalseIfFolderIsWithinDifferentStorage() {
-               $mockedStorage1 = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
-               $mockedStorage2 = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
-               $mockedFolder = new \TYPO3\CMS\Core\Resource\Folder($mockedStorage1, '/someFolder/', 'someFolder');
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ), $mockedStorage2);
-               $fileIdentifier = '/someFolder/test.jpg';
-               $subfolderIdentifier = '/someFolder/subfolder/';
-               $mockedFile = $this->getSimpleFileMock($fileIdentifier);
-               $mockedSubfolder = $this->getSimpleFolderMock($subfolderIdentifier);
-               $this->assertFalse($fixture->isWithin($mockedFolder, $mockedFile));
-               $this->assertFalse($fixture->isWithin($mockedFolder, $fileIdentifier));
-               $this->assertFalse($fixture->isWithin($mockedFolder, $mockedSubfolder));
-               $this->assertFalse($fixture->isWithin($mockedFolder, $subfolderIdentifier));
-       }
-
-       /**********************************
-        * Copy/move file
-        **********************************/
-       /**
-        * @param $identifier
-        * @param null|\TYPO3\CMS\Core\Resource\ResourceStorage $storage
-        * @return \TYPO3\CMS\Core\Resource\File
-        */
-       protected function mockFileForCopyingAndMoving($identifier, \TYPO3\CMS\Core\Resource\ResourceStorage $storage = NULL) {
-               if (!$storage) {
-                       $storage = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
-               }
-               $fileObject = new \TYPO3\CMS\Core\Resource\File(array('identifier' => $identifier, 'name' => basename($identifier), 'storage' => $storage));
-               return $fileObject;
-       }
-
-       /**
-        * @param $identifier
-        * @param null|\TYPO3\CMS\Core\Resource\ResourceStorage $storage
-        * @return \TYPO3\CMS\Core\Resource\Folder
-        */
-       protected function mockFolderForCopyingAndMoving($identifier, \TYPO3\CMS\Core\Resource\ResourceStorage $storage = NULL) {
-               if (!$storage) {
-                       $storage = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
-               }
-               $folderObject = new \TYPO3\CMS\Core\Resource\Folder($storage, $identifier, basename($identifier), 0);
-               return $folderObject;
-       }
-
-       /**
-        * Prepares a simple two-folder environment with /someFolder/ and /targetFolder/. /someFolder contains a file with random
-        * contents
-        *
-        * @return array $mockedFolder, $sourceFolder, $fileContents, $fixture
-        */
-       protected function _prepareFolderEnvironmentForMoveTest() {
-               $mockedFolder = $this->getSimpleFolderMock('/targetFolder/');
-               $sourceFolder = $this->getSimpleFolderMock('/someFolder/');
-               $fileContents = uniqid();
-               $this->addToMount(array(
-                       'targetFolder' => array(),
-                       'someFolder' => array('file' => $fileContents)
-               ));
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               return array($mockedFolder, $sourceFolder, $fileContents, $fixture);
-       }
-
-       /**
-        * @test
-        */
-       public function filesCanBeCopiedWithinStorage() {
-               $fileContents = uniqid();
-               $this->addToMount(array(
-                       'someFile' => $fileContents,
-                       'targetFolder' => array()
-               ));
-               $fixture = $this->createDriverFixture(
-                       array('basePath' => $this->getMountRootUrl()),
-                       NULL,
-                               // Mocked because finfo() can not deal with vfs streams and throws warnings
-                       array('getMimeTypeOfFile')
-               );
-               $storage = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
-               $sourceFile = $this->mockFileForCopyingAndMoving('/someFile', $storage);
-               $targetFolder = $this->mockFolderForCopyingAndMoving('/targetFolder/', $storage);
-               $fixture->copyFileWithinStorage($sourceFile, $targetFolder, 'someFile');
-               $this->assertFileEquals($this->getUrlInMount('/someFile'), $this->getUrlInMount('/targetFolder/someFile'));
-       }
-
-       /**
-        * @test
-        */
-       public function filesCanBeMovedWithinStorage() {
-               $mockedFolder = $this->getSimpleFolderMock('/targetFolder/');
-               $storage = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
-               $sourceFile = $this->mockFileForCopyingAndMoving('/someFile', $storage);
-               $fileContents = uniqid();
-               $this->addToMount(array(
-                       'targetFolder' => array(),
-                       'someFile' => $fileContents
-               ));
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               $newIdentifier = $fixture->moveFileWithinStorage($sourceFile, $mockedFolder, 'file');
-               $this->assertEquals($fileContents, file_get_contents($this->getUrlInMount('/targetFolder/file')));
-               $this->assertFileNotExists($this->getUrlInMount('/someFile'));
-               $this->assertEquals('/targetFolder/file', $newIdentifier);
-       }
-
-       /**
-        * @test
-        */
-       public function fileMetadataIsChangedAfterMovingFile() {
-               $mockedFolder = $this->getSimpleFolderMock('/targetFolder/');
-               $storage = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
-               $sourceFile = $this->mockFileForCopyingAndMoving('/someFile', $storage);
-               $fileContents = uniqid();
-               $this->addToMount(array(
-                       'targetFolder' => array(),
-                       'someFile' => $fileContents
-               ));
-               $fixture = $this->createDriverFixture(
-                       array('basePath' => $this->getMountRootUrl()),
-                       NULL,
-                               // Mocked because finfo() can not deal with vfs streams and throws warnings
-                       array('getMimeTypeOfFile')
-               );
-               $newIdentifier = $fixture->moveFileWithinStorage($sourceFile, $mockedFolder, 'file');
-               $fileMetadata = $fixture->getFileInfoByIdentifier($newIdentifier);
-               $this->assertEquals($newIdentifier, $fileMetadata['identifier']);
-       }
-
-       public function renamingFiles_dataProvider() {
-               return array(
-                       'file in subfolder' => array(
-                               array(
-                                       'targetFolder' => array('file' => '')
-                               ),
-                               '/targetFolder/file',
-                               'newFile',
-                               '/targetFolder/newFile'
-                       ),
-                       'file in rootfolder' => array(
-                               array(
-                                       'fileInRoot' => ''
-                               ),
-                               '/fileInRoot',
-                               'newFile',
-                               '/newFile'
-                       )
-               );
-       }
-
-       /**
-        * @test
-        * @dataProvider renamingFiles_dataProvider
-        */
-       public function renamingFilesChangesFilenameOnDisk(array $filesystemStructure, $oldFileIdentifier, $newFileName, $expectedNewIdentifier) {
-               $this->addToMount($filesystemStructure);
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               $file = $this->getSimpleFileMock($oldFileIdentifier);
-               $newIdentifier = $fixture->renameFile($file, $newFileName);
-               $this->assertFalse($fixture->fileExists($oldFileIdentifier));
-               $this->assertTrue($fixture->fileExists($newIdentifier));
-               $this->assertEquals($expectedNewIdentifier, $newIdentifier);
-       }
-
-       /**
-        * @test
-        */
-       public function renamingFilesFailsIfTargetFileExists() {
-               $this->setExpectedException('TYPO3\\CMS\\Core\\Resource\\Exception\\ExistingTargetFileNameException', '', 1320291063);
-               $this->addToMount(array(
-                       'targetFolder' => array('file' => '', 'newFile' => '')
-               ));
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               $file = $this->getSimpleFileMock('/targetFolder/file');
-               $fixture->renameFile($file, 'newFile');
-       }
-
-       /**
-        * We use this data provider for testing move methods because there are some issues with the
-        *
-        * @return array
-        */
-       public function renamingFolders_dataProvider() {
-               return array(
-                       'folder in root folder' => array(
-                               array(
-                                       'someFolder' => array()
-                               ),
-                               '/someFolder/',
-                               'newFolder',
-                               '/newFolder/'
-                       ),
-                       'file in subfolder' => array(
-                               array(
-                                       'subfolder' => array(
-                                               'someFolder' => array()
-                                       )
-                               ),
-                               '/subfolder/someFolder/',
-                               'newFolder',
-                               '/subfolder/newFolder/'
-                       )
-               );
-       }
-
-       /**
-        * @test
-        * @dataProvider renamingFolders_dataProvider
-        */
-       public function renamingFoldersChangesFolderNameOnDisk(array $filesystemStructure, $oldFolderIdentifier, $newFolderName, $expectedNewIdentifier) {
-               $this->addToMount($filesystemStructure);
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               $mockedFolder = $this->getSimpleFolderMock($oldFolderIdentifier);
-               $mapping = $fixture->renameFolder($mockedFolder, $newFolderName);
-               $this->assertFalse($fixture->folderExists($oldFolderIdentifier));
-               $this->assertTrue($fixture->folderExists($expectedNewIdentifier));
-               $this->assertEquals($expectedNewIdentifier, $mapping[$oldFolderIdentifier]);
-       }
-
-       /**
-        * @test
-        */
-       public function renameFolderReturnsCorrectMappingInformationForAllFiles() {
-               $fileContents = 'asdfg';
-               $this->addToMount(array(
-                       'sourceFolder' => array(
-                               'subFolder' => array('file' => $fileContents),
-                               'file' => 'asdfg'
-                       )
-               ));
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               $sourceFolder = $this->getSimpleFolderMock('/sourceFolder/');
-               $mappingInformation = $fixture->renameFolder($sourceFolder, 'newFolder');
-               $this->assertEquals('/newFolder/', $mappingInformation['/sourceFolder/']);
-               $this->assertEquals('/newFolder/file', $mappingInformation['/sourceFolder/file']);
-               $this->assertEquals('/newFolder/subFolder/file', $mappingInformation['/sourceFolder/subFolder/file']);
-               $this->assertEquals('/newFolder/subFolder/', $mappingInformation['/sourceFolder/subFolder/']);
-       }
-
-       /**
-        * @test
-        */
-       public function renameFolderRevertsRenamingIfFilenameMapCannotBeCreated() {
-               $this->setExpectedException('RuntimeException', '', 1334160746);
-               $this->addToMount(array(
-                       'sourceFolder' => array(
-                               'file' => 'asdfg'
-                       )
-               ));
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ), NULL, array('createIdentifierMap'));
-               $fixture->expects($this->atLeastOnce())->method('createIdentifierMap')->will($this->throwException(new \TYPO3\CMS\Core\Resource\Exception\FileOperationErrorException()));
-               $sourceFolder = $this->getSimpleFolderMock('/sourceFolder/');
-               $fixture->renameFolder($sourceFolder, 'newFolder');
-               $this->assertFileExists($this->getUrlInMount('/sourceFolder/file'));
-       }
-
-       /**
-        * @test
-        */
-       public function isFolderEmptyReturnsTrueForEmptyFolder() {
-               // This also prepares the next few tests, so add more info than required for this test
-               $this->addToMount(array(
-                       'emptyFolder' => array()
-               ));
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               $mockedFolder = $this->getSimpleFolderMock('/emptyFolder/');
-               $this->assertTrue($fixture->isFolderEmpty($mockedFolder));
-               return $fixture;
-       }
-
-       /**
-        * @test
-        */
-       public function isFolderEmptyReturnsFalseIfFolderHasFile() {
-               $this->addToMount(array(
-                       'folderWithFile' => array(
-                               'someFile' => ''
-                       )
-               ));
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               $mockedFolder = $this->getSimpleFolderMock('/folderWithFile/');
-               $this->assertFalse($fixture->isFolderEmpty($mockedFolder));
-       }
-
-       /**
-        * @test
-        */
-       public function isFolderEmptyReturnsFalseIfFolderHasSubfolder() {
-               $this->addToMount(array(
-                       'folderWithSubfolder' => array(
-                               'someFolder' => array()
-                       )
-               ));
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               $mockedFolder = $this->getSimpleFolderMock('/folderWithSubfolder/');
-               $this->assertFalse($fixture->isFolderEmpty($mockedFolder));
-       }
-
-       /**********************************
-        * Copy/move folder
-        **********************************/
-       /**
-        * @test
-        */
-       public function foldersCanBeMovedWithinStorage() {
-               /** @var \TYPO3\CMS\Core\Resource\Driver\LocalDriver $fixture */
-               list($mockedFolder, $sourceFolder, $fileContents, $fixture) = $this->_prepareFolderEnvironmentForMoveTest();
-               $fixture->moveFolderWithinStorage($sourceFolder, $mockedFolder, 'someFolder');
-               $this->assertTrue(file_exists($this->getUrlInMount('/targetFolder/someFolder/')));
-               $this->assertEquals($fileContents, file_get_contents($this->getUrlInMount('/targetFolder/someFolder/file')));
-               $this->assertFileNotExists($this->getUrlInMount('/someFile'));
-       }
-
-       /**
-        * @test
-        */
-       public function moveFolderWithinStorageReturnsCorrectMappingInformationForAllFiles() {
-               $fileContents = 'asdfg';
-               $this->addToMount(array(
-                       'targetFolder' => array(),
-                       'sourceFolder' => array(
-                               'subFolder' => array('file' => $fileContents),
-                               'file' => 'asdfg'
-                       )
-               ));
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               $sourceFolder = $this->getSimpleFolderMock('/sourceFolder/');
-               $targetFolder = $this->getSimpleFolderMock('/targetFolder/');
-               $mappingInformation = $fixture->moveFolderWithinStorage($sourceFolder, $targetFolder, 'sourceFolder');
-               $this->assertEquals('/targetFolder/sourceFolder/file', $mappingInformation['/sourceFolder/file']);
-               $this->assertEquals('/targetFolder/sourceFolder/subFolder/file', $mappingInformation['/sourceFolder/subFolder/file']);
-               $this->assertEquals('/targetFolder/sourceFolder/subFolder/', $mappingInformation['/sourceFolder/subFolder/']);
-       }
-
-       /**
-        * @test
-        */
-       public function folderCanBeRenamedWhenMoving() {
-               /** @var \TYPO3\CMS\Core\Resource\Driver\LocalDriver $fixture */
-               list($mockedFolder, $sourceFolder, $fileContents, $fixture) = $this->_prepareFolderEnvironmentForMoveTest();
-               $fixture->moveFolderWithinStorage($sourceFolder, $mockedFolder, 'newFolder');
-               $this->assertTrue(file_exists($this->getUrlInMount('/targetFolder/newFolder/')));
-       }
-
-       protected function _setupFolderForCopyTest() {
-               $fileContents1 = uniqid();
-               $fileContents2 = uniqid();
-               $this->addToMount(array(
-                       'targetFolder' => array(),
-                       'sourceFolder' => array(
-                               'subFolder' => array('file' => $fileContents1),
-                               'file' => $fileContents2
-                       )
-               ));
-               $fixture = $this->createDriverFixture(array(
-                       'basePath' => $this->getMountRootUrl()
-               ));
-               return $fixture;
-       }
-
-       /**
-        * @test
-        * @see _setupFolderForCopyTest
-        */
-       public function foldersCanBeCopiedWithinSameStorage() {
-               $fixture = $this->_setupFolderForCopyTest();
-               $sourceFolder = $this->getSimpleFolderMock('/sourceFolder/');
-               $targetFolder = $this->getSimpleFolderMock('/targetFolder/');
-               $fixture->copyFolderWithinStorage($sourceFolder, $targetFolder, 'sourceFolder');
-               $this->assertTrue($fixture->folderExists('/targetFolder/sourceFolder/'));
-               $this->assertTrue($fixture->fileExists('/targetFolder/sourceFolder/file'));
-               $this->assertTrue($fixture->folderExists('/targetFolder/sourceFolder/subFolder/'));
-               $this->assertTrue($fixture->fileExists('/targetFolder/sourceFolder/subFolder/file'));
-       }
-
-       /**
-        * @test
-        * @see _setupFolderForCopyTest
-        */
-       public function folderNameCanBeChangedWhileCopying() {
-               $fixture = $this->_setupFolderForCopyTest();
-               $sourceFolder = $this->getSimpleFolderMock('/sourceFolder/');
-               $targetFolder = $this->getSimpleFolderMock('/targetFolder/');
-               $fixture->copyFolderWithinStorage($sourceFolder, $targetFolder, 'newFolder');
-               $this->assertTrue($fixture->folderExists('/targetFolder/newFolder/'));
-               $this->assertTrue($fixture->fileExists('/targetFolder/newFolder/file'));
-               $this->assertFalse($fixture->folderExists('/targetFolder/sourceFolder/'));
-       }
-
-}
-?>
diff --git a/tests/Unit/t3lib/file/FactoryTest.php b/tests/Unit/t3lib/file/FactoryTest.php
deleted file mode 100644 (file)
index 29205e7..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-<?php
-/***************************************************************
- * Copyright notice
- *
- * (c) 2011 Andreas Wolf <andreas.wolf@ikt-werk.de>
- * All rights reserved
- *
- * This script is part of the TYPO3 project. The TYPO3 project is
- * free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * The GNU General Public License can be found at
- * http://www.gnu.org/copyleft/gpl.html.
- *
- * This script is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-require_once 'vfsStream/vfsStream.php';
-/**
- * Testcase for the factory of FAL
- *
- * @package TYPO3
- * @subpackage t3lib
- * @author Andreas Wolf <andreas.wolf@ikt-werk.de>
- */
-class t3lib_file_FactoryTest extends Tx_Phpunit_TestCase {
-
-       /**
-        * @var \TYPO3\CMS\Core\Resource\ResourceFactory
-        */
-       private $fixture;
-
-       /**
-        * @var bool
-        */
-       private $objectCreated = FALSE;
-
-       public function setUp() {
-               $this->fixture = new \TYPO3\CMS\Core\Resource\ResourceFactory();
-       }
-
-       protected function tearDown() {
-               \TYPO3\CMS\Core\Utility\GeneralUtility::purgeInstances();
-       }
-
-       /**********************************
-        * Storage Collections
-        **********************************/
-       /**
-        * @test
-        */
-       public function createStorageCollectionObjectCreatesCollectionWithCorrectArguments() {
-               $mockedMount = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
-               $path = uniqid();
-               $name = uniqid();
-               $storageCollection = $this->fixture->createFolderObject($mockedMount, $path, $name, 0);
-               $this->assertSame($mockedMount, $storageCollection->getStorage());
-               $this->assertEquals($path . '/', $storageCollection->getIdentifier());
-               $this->assertEquals($name, $storageCollection->getName());
-       }
-
-       /**********************************
-        * Drivers
-        **********************************/
-       /**
-        * @test
-        */
-       public function getDriverObjectAcceptsDriverClassName() {
-               $mockedDriver = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Driver\\AbstractDriver', array(), array(), '', FALSE);
-               $driverFixtureClass = get_class($mockedDriver);
-               \TYPO3\CMS\Core\Utility\GeneralUtility::addInstance($driverFixtureClass, $mockedDriver);
-               $mockedMount = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
-               $mockedRegistry = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Driver\\DriverRegistry');
-               $mockedRegistry->expects($this->once())->method('getDriverClass')->with($this->equalTo($driverFixtureClass))->will($this->returnValue($driverFixtureClass));
-               \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Resource\\Driver\\DriverRegistry', $mockedRegistry);
-               $obj = $this->fixture->getDriverObject($driverFixtureClass, array());
-               $this->assertInstanceOf('TYPO3\\CMS\\Core\\Resource\\Driver\\AbstractDriver', $obj);
-       }
-
-}
-
-?>
\ No newline at end of file
diff --git a/tests/Unit/t3lib/file/FileTest.php b/tests/Unit/t3lib/file/FileTest.php
deleted file mode 100644 (file)
index 7e60807..0000000
+++ /dev/null
@@ -1,351 +0,0 @@
-<?php
-/***************************************************************
- * Copyright notice
- *
- * (c) 2011 Andreas Wolf <andreas.wolf@ikt-werk.de>
- * All rights reserved
- *
- * This script is part of the TYPO3 project. The TYPO3 project is
- * free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * The GNU General Public License can be found at
- * http://www.gnu.org/copyleft/gpl.html.
- *
- * This script is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-require_once 'vfsStream/vfsStream.php';
-/**
- * Testcase for the file class of the TYPO3 FAL
- *
- * @package TYPO3
- * @subpackage t3lib
- * @author Andreas Wolf <andreas.wolf@ikt-werk.de>
- * @todo Many, many, many tests are skipped in this test case...
- */
-class t3lib_file_FileTest extends Tx_Phpunit_TestCase {
-
-       protected function tearDown() {
-               \TYPO3\CMS\Core\Utility\GeneralUtility::purgeInstances();
-       }
-
-       /**
-        * @return \TYPO3\CMS\Core\Resource\File
-        */
-       protected function prepareFixture() {
-               $fixture = new \TYPO3\CMS\Core\Resource\File('testfile');
-               return $fixture;
-       }
-
-       /**
-        * @test
-        * @todo Old code getAvailableProperties() needs to be replaced by current behaviour
-        */
-       public function propertiesPassedToConstructorAreAvailableViaGenericGetter() {
-               $this->markTestSkipped('TYPO3\\CMS\\Core\\Resource\\File::getAvailableProperties() does not exist');
-               $properties = array(
-                       uniqid() => uniqid(),
-                       uniqid() => uniqid(),
-                       'uid' => 1
-               );
-               $fixture = new \TYPO3\CMS\Core\Resource\File($properties);
-               $availablePropertiesBackup = \TYPO3\CMS\Core\Resource\File::getAvailableProperties();
-               \TYPO3\CMS\Core\Resource\File::setAvailableProperties(array_keys($properties));
-               foreach ($properties as $key => $value) {
-                       $this->assertTrue($fixture->hasProperty($key));
-                       $this->assertEquals($value, $fixture->getProperty($key));
-               }
-               $this->assertFalse($fixture->hasProperty(uniqid()));
-               \TYPO3\CMS\Core\Resource\File::setAvailableProperties($availablePropertiesBackup);
-               $this->setExpectedException('InvalidArgumentException', '', 1314226805);
-               $fixture->getProperty(uniqid());
-       }
-
-       /**
-        * @test
-        */
-       public function commonPropertiesAreAvailableWithOwnGetters() {
-               $properties = array(
-                       'name' => uniqid(),
-                       'storage' => $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE),
-                       'size' => 1024
-               );
-               $fixture = new \TYPO3\CMS\Core\Resource\File($properties);
-               foreach ($properties as $key => $value) {
-                       $this->assertEquals($value, call_user_func(array($fixture, 'get' . $key)));
-               }
-       }
-
-       /**
-        * @test
-        */
-       public function fileAsksRepositoryForIndexStatus() {
-               $mockedRepository = $this->getMock('TYPO3\\CMS\\Core\\Resource\\FileRepository');
-               $mockedRepository->expects($this->once())->method('getFileIndexRecord')->will($this->returnValue(array()));
-               \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Resource\\FileRepository', $mockedRepository);
-               $fixture = new \TYPO3\CMS\Core\Resource\File(array());
-               $this->assertTrue($fixture->isIndexed());
-       }
-
-       /**
-        * Tests if a file is seen as indexed if the record has a uid
-        *
-        * @test
-        */
-       public function fileIndexStatusIsTrueIfUidIsSet() {
-               $fixture = new \TYPO3\CMS\Core\Resource\File(array('uid' => 1));
-               $this->assertTrue($fixture->isIndexed());
-       }
-
-       /**
-        * @test
-        */
-       public function updatePropertiesUpdatesFileProperties() {
-               $identifier = '/' . uniqid();
-               $fixture = new \TYPO3\CMS\Core\Resource\File(array('uid' => 1, 'identifier' => '/test'));
-               $fixture->updateProperties(array('identifier' => $identifier));
-               $this->assertEquals($identifier, $fixture->getIdentifier());
-       }
-
-       /**
-        * @test
-        */
-       public function updatePropertiesLeavesPropertiesUntouchedIfNotSetInNewProperties() {
-               $fixture = new \TYPO3\CMS\Core\Resource\File(array('uid' => 1, 'foo' => 'asdf', 'identifier' => '/test'));
-               $fixture->updateProperties(array('foo' => 'foobar'));
-               $this->assertEquals('/test', $fixture->getIdentifier());
-               $this->assertEquals('/test', $fixture->getProperty('identifier'));
-       }
-
-       /**
-        * @test
-        */
-       public function updatePropertiesDiscardsUidIfAlreadySet() {
-               $fixture = new \TYPO3\CMS\Core\Resource\File(array('uid' => 1, 'identifier' => '/test'));
-               $fixture->updateProperties(array('uid' => 3));
-               $this->assertEquals(1, $fixture->getUid());
-       }
-
-       /**
-        * @test
-        */
-       public function updatePropertiesRecordsNamesOfChangedProperties() {
-               $fixture = new \TYPO3\CMS\Core\Resource\File(array('uid' => 1, 'foo' => 'asdf', 'baz' => 'fdsw', 'identifier' => '/test'));
-               $fixture->updateProperties(array('foo' => 'foobar', 'baz' => 'foobaz'));
-               $this->assertEquals(array('foo', 'baz'), $fixture->getUpdatedProperties());
-       }
-
-       /**
-        * @test
-        */
-       public function updatePropertiesDoesNotRecordPropertyNameIfSameValueIsProvided() {
-               $fixture = new \TYPO3\CMS\Core\Resource\File(array('uid' => 1, 'foo' => 'asdf', 'identifier' => '/test'));
-               $fixture->updateProperties(array('foo' => 'asdf'));
-               $this->assertEmpty($fixture->getUpdatedProperties());
-       }
-
-       /**
-        * @test
-        */
-       public function updatePropertiesMarksPropertyAsChangedOnlyOnce() {
-               $fixture = new \TYPO3\CMS\Core\Resource\File(array('uid' => 1, 'foo' => 'asdf', 'baz' => 'fdsw', 'identifier' => '/test'));
-               $fixture->updateProperties(array('foo' => 'foobar', 'baz' => 'foobaz'));
-               $fixture->updateProperties(array('foo' => 'fdsw', 'baz' => 'asdf'));
-               $this->assertEquals(array('foo', 'baz'), $fixture->getUpdatedProperties());
-       }
-
-       /**
-        * @test
-        */
-       public function updatePropertiesReloadsStorageObjectIfStorageChanges() {
-               $mockedNewStorage = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
-               $mockedOldStorage = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
-               $fixture = new \TYPO3\CMS\Core\Resource\File(array('uid' => 1, 'foo' => 'asdf', 'baz' => 'fdsw', 'identifier' => '/test', 'storage' => $mockedOldStorage));
-               $mockedRepository = $this->getMock('TYPO3\\CMS\\Core\\Resource\\StorageRepository');
-               $mockedRepository->expects($this->once())->method('findByUid')->with(2)->will($this->returnValue($mockedNewStorage));
-               \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Resource\\StorageRepository', $mockedRepository);
-               $fixture->updateProperties(array('storage' => 2));
-               $this->assertSame($mockedNewStorage, $fixture->getStorage());
-       }
-
-       /**
-        * @test
-        */
-       public function fetchingIndexedPropertyCausesFileObjectToLoadIndexRecord() {
-               $fixture = new \TYPO3\CMS\Core\Resource\File(array('identifier' => '/test', 'storage' => 1));
-               $mockedRepository = $this->getMock('TYPO3\\CMS\\Core\\Resource\\FileRepository');
-               $mockedRepository->expects($this->once())->method('getFileIndexRecord')->will($this->returnValue(array('uid' => 10)));
-               \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Resource\\FileRepository', $mockedRepository);
-               $this->assertEquals(10, $fixture->getProperty('uid'));
-       }
-
-       /**
-        * @test
-        */
-       public function isIndexedTriggersIndexingIfFileIsNotIndexedAlready() {
-               $fixture = new \TYPO3\CMS\Core\Resource\File(array('identifier' => '/test', 'storage' => 1));
-               $mockedRepository = $this->getMock('TYPO3\\CMS\\Core\\Resource\\FileRepository');
-               $mockedRepository->expects($this->once())->method('getFileIndexRecord')->will($this->returnValue(FALSE));
-               $mockedRepository->expects($this->once())->method('addToIndex')->will($this->returnValue(array('uid' => 10)));
-               \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Resource\\FileRepository', $mockedRepository);
-               $fixture->isIndexed();
-       }
-
-       /**
-        * @test
-        */
-       public function fileIsAutomaticallyIndexedOnPropertyAccessIfNotAlreadyIndexed() {
-               $fixture = new \TYPO3\CMS\Core\Resource\File(array('identifier' => '/test', 'storage' => 1));
-               $mockedRepository = $this->getMock('TYPO3\\CMS\\Core\\Resource\\FileRepository');
-               $mockedRepository->expects($this->once())->method('getFileIndexRecord')->will($this->returnValue(FALSE));
-               $mockedRepository->expects($this->once())->method('addToIndex')->will($this->returnValue(array('uid' => 10)));
-               \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Resource\\FileRepository', $mockedRepository);
-               $this->assertEquals(10, $fixture->getProperty('uid'));
-       }
-
-       /**
-        * @test
-        */
-       public function copyToCallsCopyOperationOnTargetFolderStorage() {
-               $targetStorage = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
-               $targetFolder = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Folder', array(), array(), '', FALSE);
-               $targetFolder->expects($this->any())->method('getStorage')->will($this->returnValue($targetStorage));
-               $fixture = new \TYPO3\CMS\Core\Resource\File(array());
-               $targetStorage->expects($this->once())->method('copyFile')->with($this->equalTo($fixture), $this->equalTo($targetFolder));
-               $fixture->copyTo($targetFolder);
-       }
-
-       /**
-        * @test
-        */
-       public function moveToCallsMoveOperationOnTargetFolderStorage() {
-               $targetStorage = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
-               $targetFolder = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Folder', array(), array(), '', FALSE);
-               $targetFolder->expects($this->any())->method('getStorage')->will($this->returnValue($targetStorage));
-               $fixture = new \TYPO3\CMS\Core\Resource\File(array());
-               $targetStorage->expects($this->once())->method('moveFile')->with($this->equalTo($fixture), $this->equalTo($targetFolder));
-               $fixture->moveTo($targetFolder);
-       }
-
-       /**
-        * @test
-        */
-       public function openCorrectlyOpensFileInDriver() {
-               $this->markTestSkipped();
-               $fixture = $this->prepareFixture();
-               $fileMode = 'invalidMode';
-               $mockDriver = $this->getMockForAbstractClass('t3lib_file_driver_Abstract');
-               $mockDriver->expects($this->atLeastOnce())->method('getFileHandle')->with($this->equalTo($fixture), $this->equalTo($fileMode));
-               $fixture->setStorageDriver($mockDriver);
-               $fixture->open($fileMode);
-       }
-
-       /**
-        * @test
-        */
-       public function isOpenReturnsCorrectValuesForClosedAndOpenFile() {
-               $this->markTestSkipped();
-               $fixture = $this->prepareFixture();
-               $fileMode = 'r';
-               $mockFileHandle = $this->getMock('TYPO3\\CMS\\Core\\Resource\\FileHandle', array(), array(), '', FALSE);
-               $mockFileHandle->expects($this->any())->method('isOpen')->will($this->returnValue(TRUE));
-               $mockDriver = $this->getMockForAbstractClass('t3lib_file_driver_Abstract');
-               $mockDriver->expects($this->any())->method('getFileHandle')->will($this->returnValue($mockFileHandle));
-               $fixture->setStorageDriver($mockDriver);
-               $this->assertFalse($fixture->isOpen());
-               $fixture->open($fileMode);
-               $this->assertTrue($fixture->isOpen());
-       }
-
-       /**
-        * @test
-        */
-       public function fileIsCorrectlyClosed() {
-               $this->markTestSkipped();
-               $fixture = $this->prepareFixture();
-               $fileMode = 'r';
-               $mockFileHandle = $this->getMock('TYPO3\\CMS\\Core\\Resource\\FileHandle', array(), array(), '', FALSE);
-               $mockFileHandle->expects($this->once())->method('close');
-               $mockDriver = $this->getMockForAbstractClass('t3lib_file_driver_Abstract');
-               $mockDriver->expects($this->any())->method('getFileHandle')->will($this->returnValue($mockFileHandle));
-               $fixture->setStorageDriver($mockDriver);
-               $fixture->open($fileMode);
-               $fixture->close();
-               $this->assertFalse($fixture->isOpen());
-       }
-
-       /**
-        * @test
-        */
-       public function readReturnsRequestedContentsFromDriver() {
-               $this->markTestSkipped();
-               $fixture = $this->prepareFixture();
-               $fileMode = 'r';
-               $fileContents = 'Some random file contents.';
-               $bytesToRead = 10;
-               $mockFileHandle = $this->getMock('TYPO3\\CMS\\Core\\Resource\\FileHandle', array(), array(), '', FALSE);
-               $mockFileHandle->expects($this->any())->method('isOpen')->will($this->returnValue(TRUE));
-               $mockDriver = $this->getMockForAbstractClass('t3lib_file_driver_Abstract');
-               $mockDriver->expects($this->any())->method('getFileHandle')->will($this->returnValue($mockFileHandle));
-               $mockDriver->expects($this->once())->method('readFromFile')->with($this->anything(), $this->equalTo($bytesToRead))->will($this->returnValue(substr($fileContents, 0, $bytesToRead)));
-               $fixture->setStorageDriver($mockDriver);
-               $fixture->open($fileMode);
-               $this->assertEquals(substr($fileContents, 0, $bytesToRead), $fixture->read($bytesToRead));
-       }
-
-       /**
-        * @test
-        */
-       public function readFailsIfFileIsClosed() {
-               $this->markTestSkipped();
-               $this->setExpectedException('RuntimeException', '', 1299863431);
-               $fixture = $this->prepareFixture();
-               $mockFileHandle = $this->getMock('TYPO3\\CMS\\Core\\Resource\\FileHandle', array(), array(), '', FALSE);
-               $mockDriver = $this->getMockForAbstractClass('t3lib_file_driver_Abstract');
-               $mockDriver->expects($this->any())->method('getFileHandle')->will($this->returnValue($mockFileHandle));
-               $fixture->setStorageDriver($mockDriver);
-               $fixture->read(1);
-       }
-
-       /**
-        * @test
-        */
-       public function writePassesContentsToDriver() {
-               $this->markTestSkipped();
-               $fixture = $this->prepareFixture();
-               $fileMode = 'r+';
-               $fileContents = 'Some random file contents.';
-               $mockFileHandle = $this->getMock('TYPO3\\CMS\\Core\\Resource\\FileHandle', array(), array(), '', FALSE);
-               $mockFileHandle->expects($this->any())->method('isOpen')->will($this->returnValue(TRUE));
-               $mockDriver = $this->getMockForAbstractClass('t3lib_file_driver_Abstract');
-               $mockDriver->expects($this->any())->method('getFileHandle')->will($this->returnValue($mockFileHandle));
-               $mockDriver->expects($this->once())->method('writeToFile')->with($this->anything(), $this->equalTo($fileContents))->will($this->returnValue(TRUE));
-               $fixture->setStorageDriver($mockDriver);
-               $fixture->open($fileMode);
-               $this->assertTrue($fixture->write($fileContents));
-       }
-
-       /**
-        * @test
-        */
-       public function writeFailsIfFileIsClosed() {
-               $this->markTestSkipped();
-               $this->setExpectedException('RuntimeException', '', 1299863432);
-               $fixture = $this->prepareFixture();
-               $mockFileHandle = $this->getMock('TYPO3\\CMS\\Core\\Resource\\FileHandle', array(), array(), '', FALSE);
-               $mockDriver = $this->getMockForAbstractClass('t3lib_file_driver_Abstract');
-               $mockDriver->expects($this->any())->method('getFileHandle')->will($this->returnValue($mockFileHandle));
-               $fixture->setStorageDriver($mockDriver);
-               $fixture->write('asdf');
-       }
-
-}
-
-?>
\ No newline at end of file
diff --git a/tests/Unit/t3lib/file/FolderTest.php b/tests/Unit/t3lib/file/FolderTest.php
deleted file mode 100644 (file)
index 18f60b9..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-<?php
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2011 Andreas Wolf <andreas.wolf@ikt-werk.de>
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *  A copy is found in the textfile GPL.txt and important notices to the license
- *  from the author is found in LICENSE.txt distributed with these scripts.
- *
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-require_once 'vfsStream/vfsStream.php';
-/**
- * Testcase for the storage collection class of the TYPO3 FAL
- *
- * @package TYPO3
- * @subpackage t3lib
- * @author Andreas Wolf <andreas.wolf@ikt-werk.de>
- */
-class t3lib_file_FolderTest extends Tx_Phpunit_TestCase {
-
-       private $basedir = 'basedir';
-
-       public function setUp() {
-               vfsStream::setup($this->basedir);
-       }
-
-       protected function tearDown() {
-               \TYPO3\CMS\Core\Utility\GeneralUtility::purgeInstances();
-       }
-
-       protected function createFolderFixture($path, $name, $mockedStorage = NULL) {
-               if ($mockedStorage === NULL) {
-                       $mockedStorage = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
-               }
-               return new \TYPO3\CMS\Core\Resource\Folder($mockedStorage, $path, $name, 0);
-       }
-
-       /**
-        * @test
-        */
-       public function constructorArgumentsAreAvailableAtRuntime() {
-               $path = uniqid();
-               $name = uniqid();
-               $mockedStorage = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
-               $fixture = $this->createFolderFixture($path, $name, $mockedStorage);
-               $this->assertSame($mockedStorage, $fixture->getStorage());
-               $this->assertStringStartsWith($path, $fixture->getIdentifier());
-               $this->assertEquals($name, $fixture->getName());
-       }
-
-       /**
-        * @test
-        */
-       public function propertiesCanBeUpdated() {
-               $fixture = $this->createFolderFixture('/somePath', 'someName');
-               $fixture->updateProperties(array('identifier' => '/someOtherPath', 'name' => 'someNewName'));
-               $this->assertEquals('someNewName', $fixture->getName());
-               $this->assertEquals('/someOtherPath', $fixture->getIdentifier());
-       }
-
-       /**
-        * @test
-        */
-       public function propertiesAreNotUpdatedIfNotSetInInput() {
-               $fixture = $this->createFolderFixture('/somePath/someName/', 'someName');
-               $fixture->updateProperties(array('identifier' => '/someOtherPath'));
-               $this->assertEquals('someName', $fixture->getName());
-       }
-
-       /**
-        * @test
-        */
-       public function getSubfolderCallsFactoryWithCorrectArguments() {
-               $mockedStorage = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
-               $mockedStorage->expects($this->once())->method('hasFolderInFolder')->with($this->equalTo('someSubfolder'))->will($this->returnValue(TRUE));
-               $mockedFactory = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceFactory');
-               $mockedFactory->expects($this->once())->method('createFolderObject')->with($mockedStorage, '/somePath/someFolder/someSubfolder/', 'someSubfolder');
-               \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Resource\\ResourceFactory', $mockedFactory);
-               $fixture = $this->createFolderFixture('/somePath/someFolder/', 'someFolder', $mockedStorage);
-               $fixture->getSubfolder('someSubfolder');
-       }
-
-}
-
-?>
\ No newline at end of file
diff --git a/tests/Unit/t3lib/file/Repository/AbstractRepositoryTest.php b/tests/Unit/t3lib/file/Repository/AbstractRepositoryTest.php
deleted file mode 100644 (file)
index ad8f99a..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-<?php
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2011 Andreas Wolf <andreas.wolf@ikt-werk.de>
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *  A copy is found in the textfile GPL.txt and important notices to the license
- *  from the author is found in LICENSE.txt distributed with these scripts.
- *
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-/**
- * Testcase for the abstract repository base class
- *
- * @author Andreas Wolf <andreas.wolf@ikt-werk.de>
- * @package TYPO3
- * @subpackage t3lib
- */
-class t3lib_file_Repository_AbstractRepositoryTest extends Tx_Phpunit_TestCase {
-
-       /**
-        * @var \TYPO3\CMS\Core\Resource\AbstractRepository
-        */
-       private $fixture;
-
-       private $mockedDb;
-
-       private $Typo3DbBackup;
-
-       protected function createDatabaseMock() {
-               $this->mockedDb = $this->getMock('TYPO3\\CMS\\Core\\Database\\DatabaseConnection');
-               $this->Typo3DbBackup = $GLOBALS['TYPO3_DB'];
-               $GLOBALS['TYPO3_DB'] = $this->mockedDb;
-       }
-
-       public function setUp() {
-               $this->fixture = $this->getMockForAbstractClass('TYPO3\\CMS\\Core\\Resource\\AbstractRepository', array(), '', FALSE);
-       }
-
-       public function tearDown() {
-               if ($this->mockedDb) {
-                       $GLOBALS['TYPO3_DB'] = $this->Typo3DbBackup;
-               }
-       }
-
-       /**
-        * @test
-        */
-       public function findByUidFailsIfUidIsString() {
-               $this->setExpectedException('InvalidArgumentException', '', 1316779798);
-               $this->fixture->findByUid('asdf');
-       }
-
-       /**
-        * @test
-        */
-       public function findByUidAcceptsNumericUidInString() {
-               $this->createDatabaseMock();
-               $this->mockedDb->expects($this->once())->method('exec_SELECTgetSingleRow')->with($this->anything(), $this->anything(), $this->stringContains('uid=' . 123))->will($this->returnValue(array('uid' => 123)));
-               $this->fixture->findByUid('123');
-       }
-
-}
-
-?>
\ No newline at end of file
diff --git a/tests/Unit/t3lib/file/Service/IndexerServiceTest.php b/tests/Unit/t3lib/file/Service/IndexerServiceTest.php
deleted file mode 100644 (file)
index ffff964..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-<?php
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2011 Andreas Wolf <andreas.wolf@ikt-werk.de>
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *  A copy is found in the textfile GPL.txt and important notices to the license
- *  from the author is found in LICENSE.txt distributed with these scripts.
- *
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-/**
- * Testcase for the file indexing service
- *
- * @author Andreas Wolf <andreas.wolf@ikt-werk.de>
- * @package TYPO3
- * @subpackage t3lib
- */
-class t3lib_file_Service_IndexerServiceTest extends Tx_Phpunit_TestCase {
-
-       /**
-        * @var bool Backup all $GLOBALS
-        */
-       protected $backupGlobals = TRUE;
-
-       /**
-        * @var array Do not backup TYPO3_DB, it destroys the db resource
-        */
-       protected $backupGlobalsBlacklist = array('TYPO3_DB');
-
-       /**
-        * @var Store backup of TYPO3_DB
-        */
-       protected $dbBackup;
-
-       /**
-        * Set up this test case
-        */
-       public function setUp() {
-                       // Store TYPO3_DB in local var, it is substituted with a mock in this test
-               $this->dbBackup = $GLOBALS['TYPO3_DB'];
-       }
-
-       /**
-        * Tear down this test case
-        */
-       public function tearDown() {
-                       // Re constitute TYPO3_DB from backup
-               $GLOBALS['TYPO3_DB'] = $this->dbBackup;
-       }
-
-       /**
-        * @test
-        */
-       public function indexFileUpdatesFileProperties() {
-               $fileInfo = array(
-                       'mount' => 1,
-                       'identifier' => '/some/filepath/filename.jpg',
-                       'size' => 1234,
-                       'uid' => rand(1, 100)
-               );
-               /** @var $fixture \TYPO3\CMS\Core\Resource\Service\IndexerService */
-               $fixture = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Service\\IndexerService', array('gatherFileInformation'));
-               $fixture->expects($this->any())->method('gatherFileInformation')->will($this->returnValue($fileInfo));
-               $GLOBALS['TYPO3_DB'] = $this->getMock('TYPO3\\CMS\\Core\\Database\\DatabaseConnection', array(), array(), '', FALSE);
-               $GLOBALS['TYPO3_DB']->expects($this->atLeastOnce())->method('sql_insert_id')->will($this->returnValue($fileInfo['uid']));
-               $mockedFile = $this->getMock('TYPO3\\CMS\\Core\\Resource\\File', array(), array(), '', FALSE);
-               $mockedFile->expects($this->once())->method('updateProperties')->with($this->equalTo($fileInfo));
-               $fixture->indexFile($mockedFile);
-       }
-
-       /**
-        * @test
-        */
-       public function indexFileSetsCreationdateAndTimestampPropertiesOfRecordToCurrentExecutionTime() {
-               $fileInfo = array();
-               /** @var $fixture \TYPO3\CMS\Core\Resource\Service\IndexerService */
-               $fixture = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Service\\IndexerService', array('gatherFileInformation'));
-               $fixture->expects($this->any())->method('gatherFileInformation')->will($this->returnValue($fileInfo));
-               $GLOBALS['TYPO3_DB'] = $this->getMock('TYPO3\\CMS\\Core\\Database\\DatabaseConnection', array(), array(), '', FALSE);
-               $GLOBALS['TYPO3_DB']->expects($this->once())->method('exec_INSERTquery')->with($this->anything(), $this->equalTo(array(
-                       'crdate' => $GLOBALS['EXEC_TIME'],
-                       'tstamp' => $GLOBALS['EXEC_TIME']
-               )));
-               $mockedFile = $this->getMock('TYPO3\\CMS\\Core\\Resource\\File', array(), array(), '', FALSE);
-               $fixture->indexFile($mockedFile);
-       }
-
-}
-
-?>
\ No newline at end of file
diff --git a/tests/Unit/t3lib/file/StorageTest.php b/tests/Unit/t3lib/file/StorageTest.php
deleted file mode 100644 (file)
index c573f90..0000000
+++ /dev/null
@@ -1,592 +0,0 @@
-<?php
-/***************************************************************
- * Copyright notice
- *
- * (c) 2011 Andreas Wolf <andreas.wolf@ikt-werk.de>
- * All rights reserved
- *
- * This script is part of the TYPO3 project. The TYPO3 project is
- * free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * The GNU General Public License can be found at
- * http://www.gnu.org/copyleft/gpl.html.
- *
- * This script is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-require_once 'vfsStream/vfsStream.php';
-require_once dirname(__FILE__) . '/BaseTestCase.php';
-/**
- * Testcase for the VFS mount class
- *
- * @package TYPO3
- * @subpackage t3lib
- * @author Andreas Wolf <andreas.wolf@ikt-werk.de>
- */
-class t3lib_file_StorageTest extends t3lib_file_BaseTestCase {
-
-       /**
-        * @var \TYPO3\CMS\Core\Resource\ResourceStorage
-        */
-       private $fixture;
-
-       /**
-        * @param array $configuration
-        * @param bool $mockPermissionChecks
-        */
-       protected function prepareFixture($configuration, $mockPermissionChecks = FALSE, $driverObject = NULL, array $storageRecord = array()) {
-               $permissionMethods = array('isFileActionAllowed', 'isFolderActionAllowed', 'checkFileActionPermission', 'checkUserActionPermission');
-               $mockedMethods = NULL;
-               $configuration = $this->convertConfigurationArrayToFlexformXml($configuration);
-               $storageRecord = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($storageRecord, array(
-                       'configuration' => $configuration
-               ));
-               if ($driverObject == NULL) {
-                       /** @var $mockedDriver \TYPO3\CMS\Core\Resource\Driver\AbstractDriver */
-                       $driverObject = $this->getMockForAbstractClass('TYPO3\\CMS\\Core\\Resource\\Driver\\AbstractDriver', array(), '', FALSE);
-               }
-               if ($mockPermissionChecks) {
-                       $mockedMethods = $permissionMethods;
-               }
-               if ($mockedMethods === NULL) {
-                       $this->fixture = new \TYPO3\CMS\Core\Resource\ResourceStorage($driverObject, $storageRecord);
-               } else {
-                       $this->fixture = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', $mockedMethods, array($driverObject, $storageRecord));
-                       foreach ($permissionMethods as $method) {
-                               $this->fixture->expects($this->any())->method($method)->will($this->returnValue(TRUE));
-                       }
-               }
-       }
-
-       /**
-        * Converts a simple configuration array into a FlexForm data structure serialized as XML
-        *
-        * @param array $configuration
-        * @return string
-        * @see t3lib_div::array2xml()
-        */
-       protected function convertConfigurationArrayToFlexformXml(array $configuration) {
-               $flexformArray = array('data' => array('sDEF' => array('lDEF' => array())));
-               foreach ($configuration as $key => $value) {
-                       $flexformArray['data']['sDEF']['lDEF'][$key] = array('vDEF' => $value);
-               }
-               $configuration = \TYPO3\CMS\Core\Utility\GeneralUtility::array2xml($flexformArray);
-               return $configuration;
-       }
-
-       /**
-        * Creates a driver fixture object, optionally using a given mount object.
-        *
-        * IMPORTANT: Call this only after setting up the virtual file system (with the addTo* methods)!
-        *
-        * @param $driverConfiguration
-        * @param \TYPO3\CMS\Core\Resource\ResourceStorage $storageObject
-        * @param array $mockedDriverMethods
-        * @return \TYPO3\CMS\Core\Resource\Driver\LocalDriver
-        */
-       protected function createDriverMock($driverConfiguration, \TYPO3\CMS\Core\Resource\ResourceStorage $storageObject = NULL, $mockedDriverMethods = array()) {
-               $this->initializeVfs();
-               if ($storageObject == NULL) {
-                       $storageObject = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
-               }
-               if ($mockedDriverMethods === NULL) {
-                       $driver = new \TYPO3\CMS\Core\Resource\Driver\LocalDriver($driverConfiguration);
-               } else {
-                       // we are using the LocalDriver here because PHPUnit can't mock concrete methods in abstract classes, so
-                       // when using the AbstractDriver we would be in trouble when wanting to mock away some concrete method
-                       $driver = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Driver\\LocalDriver', $mockedDriverMethods, array($driverConfiguration));
-               }
-               $storageObject->setDriver($driver);
-               $driver->setStorage($storageObject);
-               $driver->processConfiguration();
-               $driver->initialize();
-               return $driver;
-       }
-
-       /**
-        * @test
-        */
-       public function baseUriGetsSlashAppended() {
-               $uri = 'http://example.org/somewhere/else';
-               $this->prepareFixture(array('baseUri' => $uri));
-               $this->assertEquals($uri . '/', $this->fixture->getBaseUri());
-       }
-
-       public function capabilitiesDataProvider() {
-               return array(
-                       'only public' => array(
-                               array(
-                                       'public' => TRUE,
-                                       'writable' => FALSE,
-                                       'browsable' => FALSE
-                               )
-                       ),
-                       'only writable' => array(
-                               array(
-                                       'public' => FALSE,
-                                       'writable' => TRUE,
-                                       'browsable' => FALSE
-                               )
-                       ),
-                       'only browsable' => array(
-                               array(
-                                       'public' => FALSE,
-                                       'writable' => FALSE,
-                                       'browsable' => TRUE
-                               )
-                       ),
-                       'all capabilities' => array(
-                               array(
-                                       'public' => TRUE,
-                                       'writable' => TRUE,
-                                       'browsable' => TRUE
-                               )
-                       ),
-                       'none' => array(
-                               array(
-                                       'public' => FALSE,
-                                       'writable' => FALSE,
-                                       'browsable' => FALSE
-                               )
-                       )
-               );
-       }
-
-       /**
-        * @test
-        * @dataProvider capabilitiesDataProvider
-        */
-       public function capabilitiesOfStorageObjectAreCorrectlySet(array $capabilites) {
-               $storageRecord = array(
-                       'is_public' => $capabilites['public'],
-                       'is_writable' => $capabilites['writable'],
-                       'is_browsable' => $capabilites['browsable'],
-                       'is_online' => TRUE
-               );
-               $mockedDriver = $this->createDriverMock(array(), $this->fixture, array('hasCapability'));
-               $mockedDriver->expects($this->any())->method('hasCapability')->will($this->returnValue(TRUE));
-               $this->prepareFixture(array(), FALSE, $mockedDriver, $storageRecord);
-               $this->assertEquals($capabilites['public'], $this->fixture->isPublic(), 'Capability "public" is not correctly set.');
-               $this->assertEquals($capabilites['writable'], $this->fixture->isWritable(), 'Capability "writable" is not correctly set.');
-               $this->assertEquals($capabilites['browsable'], $this->fixture->isBrowsable(), 'Capability "browsable" is not correctly set.');
-       }
-
-       /**
-        * @test
-        */
-       public function fileAndFolderListFiltersAreInitializedWithDefaultFilters() {
-               $this->prepareFixture(array());
-               $this->assertEquals($GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['callbackFilterMethods'], $this->fixture->getFileAndFolderNameFilters());
-       }
-
-       /**
-        * @test
-        */
-       public function addFileFailsIfFileDoesNotExist() {
-               $mockedFolder = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Folder', array(), array(), '', FALSE);
-               $this->setExpectedException('InvalidArgumentException', '', 1319552745);
-               $this->prepareFixture(array());
-               $this->fixture->addFile('/some/random/file', $mockedFolder);
-       }
-
-       /**
-        * @test
-        */
-       public function addFileCallsDriverWithCorrectArguments() {
-               $mockedFolder = $this->getSimpleFolderMock('/targetFolder/');
-               $this->addToMount(array(
-                       'targetFolder' => array(),
-                       'file.ext' => 'ajslkd'
-               ));
-               $this->initializeVfs();
-               $localFilePath = $this->getUrlInMount('file.ext');
-               $this->prepareFixture(array());
-               /** @var $driver \TYPO3\CMS\Core\Resource\Driver\LocalDriver */
-               $driver = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Driver\\LocalDriver', array('addFile'), array(array('basePath' => $this->getUrlInMount('targetFolder/'))));
-               $driver->expects($this->once())->method('addFile')->with($this->equalTo($localFilePath), $this->anything(), $this->equalTo('file.ext'));
-               $this->fixture->setDriver($driver);
-               $this->fixture->addFile($localFilePath, $mockedFolder);
-       }
-
-       /**
-        * @test
-        */
-       public function addFileChangesFilenameIfFileExists() {
-               $mockedFolder = $this->getSimpleFolderMock('/');
-               $this->addToMount(array(
-                       'targetFolder' => array(
-                               'file.ext' => 'asdf',
-                               'file_01.ext' => 'asjdlkajs'
-                       ),
-                       'file.ext' => 'ajslkd'
-               ));
-               $this->initializeVfs();
-               $this->prepareFixture(array());
-               /** @var $driver \TYPO3\CMS\Core\Resource\Driver\LocalDriver */
-               $driver = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Driver\\LocalDriver', array('addFile', 'fileExistsInFolder'), array(array('basePath' => $this->getUrlInMount('targetFolder/'))));
-               $driver->expects($this->once())->method('addFile')->with($this->anything(), $this->anything(), $this->equalTo('file_02.ext'));
-               $driver->expects($this->exactly(3))->method('fileExistsInFolder')->will($this->onConsecutiveCalls($this->returnValue(TRUE), $this->returnValue(TRUE), $this->returnValue(FALSE)));
-               $this->fixture->setDriver($driver);
-               $this->fixture->addFile($this->getUrlInMount('file.ext'), $mockedFolder);
-       }
-
-       /**
-        * Data provider for checkFolderPermissionsRespectsFilesystemPermissions
-        *
-        * @return array
-        */
-       public function checkFolderPermissionsFilesystemPermissionsDataProvider() {
-               return array(
-                       'read action on readable/writable folder' => array(
-                               'read',
-                               array('r' => TRUE, 'w' => TRUE),
-                       ),
-                       'read action on unreadable folder' => array(
-                               'read',
-                               array('r' => FALSE, 'w' => TRUE),
-                               'TYPO3\\CMS\\Core\\Resource\\Exception\\InsufficientFolderReadPermissionsException'
-                       ),
-                       'write action on read-only folder' => array(
-                               'write',
-                               array('r' => TRUE, 'w' => FALSE),
-                               'TYPO3\\CMS\\Core\\Resource\\Exception\\InsufficientFolderWritePermissionsException'
-                       )
-               );
-       }
-
-       /**
-        * @test
-        * @dataProvider checkFolderPermissionsFilesystemPermissionsDataProvider
-        * @param string $action 'read' or 'write'
-        * @param array $permissionsFromDriver The permissions as returned from the driver
-        * @param bool $expectedException
-        */
-       public function checkFolderPermissionsRespectsFilesystemPermissions($action, $permissionsFromDriver, $expectedException = '') {
-               $mockedDriver = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Driver\\LocalDriver');
-               $mockedDriver->expects($this->any())->method('getFolderPermissions')->will($this->returnValue($permissionsFromDriver));
-               $mockedFolder = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Folder', array(), array(), '', FALSE);
-               // let all other checks pass
-               /** @var $fixture \TYPO3\CMS\Core\Resource\ResourceStorage */
-               $fixture = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array('isWritable', 'isBrowsable', 'checkUserActionPermission'), array($mockedDriver, array()), '', FALSE);
-               $fixture->expects($this->any())->method('isWritable')->will($this->returnValue(TRUE));
-               $fixture->expects($this->any())->method('isBrowsable')->will($this->returnValue(TRUE));
-               $fixture->expects($this->any())->method('checkUserActionPermission')->will($this->returnValue(TRUE));
-               $fixture->setDriver($mockedDriver);
-               if ($expectedException == '') {
-                       $this->assertTrue($fixture->checkFolderActionPermission($action, $mockedFolder));
-               } else {
-                       $this->markTestSkipped('The exception has been disable in TYPO3\\CMS\\Core\\Resource\\ResourceStorage');
-                       $this->setExpectedException($expectedException);
-                       $fixture->checkFolderActionPermission($action, $mockedFolder);
-               }
-       }
-
-       /**
-        * @test
-        */
-       public function checkUserActionPermissionsAlwaysReturnsTrueIfNoUserPermissionsAreSet() {
-               $this->prepareFixture(array());
-               $this->assertTrue($this->fixture->checkUserActionPermission('read', 'folder'));
-       }
-
-       /**
-        * @test
-        */
-       public function checkUserActionPermissionReturnsFalseIfPermissionIsSetToZero() {
-               $this->prepareFixture(array());
-               $this->fixture->injectUserPermissions(array('readFolder' => TRUE, 'writeFile' => TRUE));
-               $this->assertTrue($this->fixture->checkUserActionPermission('read', 'folder'));
-       }
-
-       public function checkUserActionPermission_arbitraryPermissionDataProvider() {
-               return array(
-                       'all lower cased' => array(
-                               array('readFolder' => TRUE),
-                               'read',
-                               'folder'
-                       ),
-                       'all upper case' => array(
-                               array('readFolder' => TRUE),
-                               'READ',
-                               'FOLDER'
-                       ),
-                       'mixed case' => array(
-                               array('readFolder' => TRUE),
-                               'ReaD',
-                               'FoLdEr'
-                       )
-               );
-       }
-
-       /**
-        * @test
-        * @dataProvider checkUserActionPermission_arbitraryPermissionDataProvider
-        */
-       public function checkUserActionPermissionAcceptsArbitrarilyCasedArguments($permissions, $action, $type) {
-               $this->prepareFixture(array());
-               $this->fixture->injectUserPermissions($permissions);
-               $this->assertTrue($this->fixture->checkUserActionPermission($action, $type));
-       }
-
-       /**
-        * @test
-        */
-       public function userActionIsDisallowedIfPermissionIsSetToFalse() {
-               $this->prepareFixture(array());
-               $this->fixture->injectUserPermissions(array('readFolder' => FALSE));
-               $this->assertFalse($this->fixture->checkUserActionPermission('read', 'folder'));
-       }
-
-       /**
-        * @test
-        */
-       public function userActionIsDisallowedIfPermissionIsNotSet() {
-               $this->prepareFixture(array());
-               $this->fixture->injectUserPermissions(array('readFolder' => TRUE));
-               $this->assertFalse($this->fixture->checkUserActionPermission('write', 'folder'));
-       }
-
-       /**
-        * @test
-        * @group integration
-        */
-       public function setFileContentsUpdatesObjectProperties() {
-               $fileContents = 'asdf';
-               $this->initializeVfs();
-               $this->prepareFixture(array(), TRUE);
-               $fileProperties = array(
-                       'someProperty' => 'value',
-                       'someOtherProperty' => 42
-               );
-               $hash = 'asdfg';
-               $driver = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Driver\\LocalDriver', array(), array(array('basePath' => $this->getMountRootUrl())));
-               $driver->expects($this->once())->method('getFileInfo')->will($this->returnValue($fileProperties));
-               $driver->expects($this->once())->method('hash')->will($this->returnValue($hash));
-               $this->fixture->setDriver($driver);
-               $mockedFile = $this->getMock('TYPO3\\CMS\\Core\\Resource\\File', array(), array(), '', FALSE);
-               $mockedFile->expects($this->any())->method('getIdentifier')->will($this->returnValue('/file.ext'));
-               $mockedFile->expects($this->once())->method('updateProperties')->with($this->equalTo(array_merge($fileProperties, array('sha1' => $hash))));
-               $this->fixture->setFileContents($mockedFile, uniqid());
-       }
-
-       /**
-        * @test
-        * @group integration
-        */
-       public function moveFileCallsDriversRawMethodsWithCorrectArguments() {
-               $localFilePath = '/path/to/localFile';
-               $sourceFileIdentifier = '/sourceFile.ext';
-               $this->addToMount(array(
-                       'targetFolder' => array()
-               ));
-               $this->initializeVfs();
-               $targetFolder = $this->getSimpleFolderMock('/targetFolder/');
-               $sourceDriver = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Driver\\LocalDriver');
-               $sourceDriver->expects($this->once())->method('deleteFileRaw')->with($this->equalTo($sourceFileIdentifier));
-               $configuration = $this->convertConfigurationArrayToFlexformXml(array());
-               $sourceStorage = new \TYPO3\CMS\Core\Resource\ResourceStorage($sourceDriver, array('configuration' => $configuration));
-               $sourceFile = $this->getSimpleFileMock($sourceFileIdentifier);
-               $sourceFile->expects($this->once())->method('getForLocalProcessing')->will($this->returnValue($localFilePath));
-               $sourceFile->expects($this->any())->method('getStorage')->will($this->returnValue($sourceStorage));
-               /** @var $driver \TYPO3\CMS\Core\Resource\Driver\LocalDriver */
-               $driver = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Driver\\LocalDriver', array(), array(array('basePath' => $this->getMountRootUrl())));
-               $driver->expects($this->once())->method('addFileRaw')->with($localFilePath, $targetFolder, $this->equalTo('file.ext'))->will($this->returnValue('/targetFolder/file.ext'));
-               /** @var $fixture \TYPO3\CMS\Core\Resource\ResourceStorage */
-               $fixture = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array('checkFileMovePermissions', 'updateFile'), array($driver, array('configuration' => $configuration)));
-               $fixture->expects($this->once())->method('updateFile')->with($this->equalTo($sourceFile), $this->equalTo('/targetFolder/file.ext'));
-               $fixture->moveFile($sourceFile, $targetFolder, 'file.ext');
-       }
-
-       /**
-        * @test
-        * @group integration
-        */
-       public function copyFileCallsDriversRawMethodsWithCorrectArguments() {
-               $localFilePath = '/path/to/localFile';
-               $sourceFileIdentifier = '/sourceFile.ext';
-               $this->addToMount(array(
-                       'targetFolder' => array()
-               ));
-               $this->initializeVfs();
-               $targetFolder = $this->getSimpleFolderMock('/targetFolder/');
-               $storageConfiguration = $this->convertConfigurationArrayToFlexformXml(array());
-               $sourceStorage = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
-               $sourceFile = $this->getSimpleFileMock($sourceFileIdentifier);
-               $sourceFile->expects($this->once())->method('getForLocalProcessing')->will($this->returnValue($localFilePath));
-               $sourceFile->expects($this->any())->method('getStorage')->will($this->returnValue($sourceStorage));
-               /** @var $driver \TYPO3\CMS\Core\Resource\Driver\LocalDriver */
-               $driver = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Driver\\LocalDriver', array(), array(array('basePath' => $this->getMountRootUrl())));
-               $driver->expects($this->once())->method('addFile')->with($localFilePath, $targetFolder, $this->equalTo('file.ext'));
-               /** @var $fixture \TYPO3\CMS\Core\Resource\ResourceStorage */
-               $fixture = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array('checkFileCopyPermissions'), array($driver, array('configuration' => $storageConfiguration)));
-               $fixture->copyFile($sourceFile, $targetFolder, 'file.ext');
-       }
-
-       /**
-        * @test
-        * @group integration
-        */
-       public function storageUsesInjectedFilemountsToCheckForMountBoundaries() {
-               $mockedFile = $this->getSimpleFileMock('/mountFolder/file');
-               $this->addToMount(array(
-                       'mountFolder' => array(
-                               'file' => 'asdfg'
-                       )
-               ));
-               $mockedDriver = $this->createDriverMock(array('basePath' => $this->getMountRootUrl()), NULL, NULL);
-               $this->initializeVfs();
-               $this->prepareFixture(array(), NULL, $mockedDriver);
-               $this->fixture->injectFileMount('/mountFolder');
-               $this->assertEquals(1, count($this->fixture->getFileMounts()));
-               $this->fixture->isWithinFileMountBoundaries($mockedFile);
-       }
-
-       /**
-        * This test is also valid for folders
-        *
-        * @test
-        */
-       public function getFileListReturnsFilesInCorrectOrder() {
-               $fileList = array(
-                       'file10' => '',
-                       'file2' => '',
-                       'File' => '',
-                       'fail' => ''
-               );
-               $this->prepareFixture(array());
-               $driver = $this->createDriverMock(array('basePath' => $this->getMountRootUrl()), $this->fixture, array('getFileList'));
-               $driver->expects($this->once())->method('getFileList')->will($this->returnValue($fileList));
-               $fileList = $this->fixture->getFileList('/');
-               $this->assertEquals(array('fail', 'File', 'file2', 'file10'), array_keys($fileList));
-       }
-
-       /**
-        * @test
-        */
-       public function getFileListIgnoresCasingWhenSortingFilenames() {
-               $fileList = array(
-                       'aFile' => 'dfsdg',
-                       'zFile' => 'werw',
-                       'BFile' => 'asd',
-                       '12345' => 'fdsa',
-                       'IMG_1234.jpg' => 'asdf'
-               );
-               $this->prepareFixture(array());
-               $driver = $this->createDriverMock(array(), $this->fixture, array('getFileList'));
-               $driver->expects($this->once())->method('getFileList')->will($this->returnValue($fileList));
-               $fileList = $this->fixture->getFileList('/');
-               $this->assertEquals(array('12345', 'aFile', 'BFile', 'IMG_1234.jpg', 'zFile'), array_keys($fileList));
-       }
-
-       /**
-        * @test
-        */
-       public function createFolderChecksIfParentFolderExistsBeforeCreatingFolder() {
-               $mockedParentFolder = $this->getSimpleFolderMock('/someFolder/');
-               $mockedDriver = $this->createDriverMock(array());
-               $mockedDriver->expects($this->once())->method('folderExists')->with($this->equalTo('/someFolder/'))->will($this->returnValue(TRUE));
-               $mockedDriver->expects($this->once())->method('createFolder')->with($this->equalTo('newFolder'))->will($this->returnValue($mockedParentFolder));
-               $this->prepareFixture(array(), TRUE);
-               $this->fixture->setDriver($mockedDriver);
-               $this->fixture->createFolder('newFolder', $mockedParentFolder);
-       }
-
-       /**
-        * @test
-        */
-       public function createFolderCallsDriverForFolderCreation() {
-               $mockedParentFolder = $this->getSimpleFolderMock('/someFolder/');
-               $this->prepareFixture(array(), TRUE);
-               $mockedDriver = $this->createDriverMock(array(), $this->fixture);
-               $mockedDriver->expects($this->once())->method('createFolder')->with($this->equalTo('newFolder'), $this->equalTo($mockedParentFolder))->will($this->returnValue(TRUE));
-               $mockedDriver->expects($this->once())->method('folderExists')->with($this->equalTo('/someFolder/'))->will($this->returnValue(TRUE));
-               $this->fixture->createFolder('newFolder', $mockedParentFolder);
-       }
-
-       /**
-        * @test
-        */
-       public function createFolderCanRecursivelyCreateFolders() {
-               $this->addToMount(array('someFolder' => array()));
-               $mockedDriver = $this->createDriverMock(array('basePath' => $this->getMountRootUrl()), NULL, NULL);
-               $this->prepareFixture(array(), TRUE, $mockedDriver);
-               $parentFolder = $this->fixture->getFolder('/someFolder/');
-               $newFolder = $this->fixture->createFolder('subFolder/secondSubfolder', $parentFolder);
-               $this->assertEquals('secondSubfolder', $newFolder->getName());
-               $this->assertFileExists($this->getUrlInMount('/someFolder/subFolder/'));
-               $this->assertFileExists($this->getUrlInMount('/someFolder/subFolder/secondSubfolder/'));
-       }
-
-       /**
-        * @test
-        */
-       public function createFolderIgnoresLeadingAndTrailingSlashesWithFoldername() {
-               $mockedParentFolder = $this->getSimpleFolderMock('/someFolder/');
-               $this->prepareFixture(array(), TRUE);
-               $mockedDriver = $this->createDriverMock(array(), $this->fixture);
-               $mockedDriver->expects($this->once())->method('folderExists')->with($this->equalTo('/someFolder/'))->will($this->returnValue(TRUE));
-               $mockedDriver->expects($this->once())->method('createFolder')->with($this->equalTo('subFolder'));
-               $this->fixture->createFolder('/subFolder/', $mockedParentFolder);
-       }
-
-       /**
-        * @test
-        */
-       public function createFolderUsesRootFolderAsParentFolderIfNotGiven() {
-               $mockedRootFolder = $this->getSimpleFolderMock('/');
-               $this->prepareFixture(array(), TRUE);
-               $mockedDriver = $this->createDriverMock(array(), $this->fixture);
-               $mockedDriver->expects($this->once())->method('getRootLevelFolder')->with()->will($this->returnValue($mockedRootFolder));
-               $mockedDriver->expects($this->once())->method('folderExists')->with($this->equalTo('/'))->will($this->returnValue(TRUE));
-               $mockedDriver->expects($this->once())->method('createFolder')->with($this->equalTo('someFolder'));
-               $this->fixture->createFolder('someFolder');
-       }
-
-       /**
-        * @test
-        */
-       public function createFolderCreatesNestedStructureEvenIfPartsAlreadyExist() {
-               $this->addToMount(array(
-                       'existingFolder' => array()
-               ));
-               $this->initializeVfs();
-               $mockedDriver = $this->createDriverMock(array('basePath' => $this->getMountRootUrl()), NULL, NULL);
-               $this->prepareFixture(array(), TRUE, $mockedDriver);
-               $rootFolder = $this->fixture->getFolder('/');
-               $newFolder = $this->fixture->createFolder('existingFolder/someFolder', $rootFolder);
-               $this->assertEquals('someFolder', $newFolder->getName());
-               $this->assertFileExists($this->getUrlInMount('existingFolder/someFolder'));
-       }
-
-       /**
-        * @test
-        */
-       public function createFolderThrowsExceptionIfParentFolderDoesNotExist() {
-               $this->setExpectedException('InvalidArgumentException', '', 1325689164);
-               $mockedParentFolder = $this->getSimpleFolderMock('/someFolder/');
-               $this->prepareFixture(array(), TRUE);
-               $mockedDriver = $this->createDriverMock(array(), $this->fixture);
-               $mockedDriver->expects($this->once())->method('folderExists')->with($this->equalTo('/someFolder/'))->will($this->returnValue(FALSE));
-               $this->fixture->createFolder('newFolder', $mockedParentFolder);
-       }
-
-       /**
-        * @test
-        */
-       public function replaceFileFailsIfLocalFileDoesNotExist() {
-               $this->setExpectedException('InvalidArgumentException', '', 1325842622);
-               $this->prepareFixture(array(), TRUE);
-               $mockedFile = $this->getSimpleFileMock('/someFile');
-               $this->fixture->replaceFile($mockedFile, PATH_site . uniqid());
-       }
-
-}
-
-?>
\ No newline at end of file
diff --git a/tests/Unit/t3lib/file/Utility/FileExtensionFilterTest.php b/tests/Unit/t3lib/file/Utility/FileExtensionFilterTest.php
deleted file mode 100644 (file)
index 015a564..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-<?php
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2012 Oliver Hader <oliver.hader@typo3.org>
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *  A copy is found in the textfile GPL.txt and important notices to the license
- *  from the author is found in LICENSE.txt distributed with these scripts.
- *
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-/**
- * Test suite for filtering files by their extensions.
- *
- * @author Oliver Hader <oliver.hader@typo3.org>
- * @package TYPO3
- * @subpackage t3lib
- */
-class t3lib_file_Utility_FileExtensionFilterTest extends Tx_Phpunit_TestCase {
-
-       /**
-        * @var \TYPO3\CMS\Core\Resource\Filter\FileExtensionFilter
-        */
-       protected $filter;
-
-       /**
-        * @var array
-        */
-       protected $parameters;
-
-       /**
-        * @var t3lib_TCEmain|PHPUnit_Framework_MockObject_MockObject
-        */
-       protected $tceMainMock;
-
-       /**
-        * @var \TYPO3\CMS\Core\Resource\ResourceFactory|PHPUnit_Framework_MockObject_MockObject
-        */
-       protected $fileFactoryMock;
-
-       /**
-        * Sets up this test suite.
-        */
-       protected function setUp() {
-               $this->filter = new \TYPO3\CMS\Core\Resource\Filter\FileExtensionFilter();
-               $this->tceMainMock = $this->getMock('TYPO3\\CMS\\Core\\DataHandler\\DataHandler', array('deleteAction'), array());
-               $this->fileFactoryMock = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceFactory', array('getFileReferenceObject'), array());
-               \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Resource\\ResourceFactory', $this->fileFactoryMock);
-       }
-
-       /**
-        * Cleans up this test suite.
-        */
-       protected function tearDown() {
-               unset($this->fileFactoryMock);
-               unset($this->tceMainMock);
-               unset($this->parameters);
-               unset($this->filter);
-               \TYPO3\CMS\Core\Utility\GeneralUtility::purgeInstances();
-       }
-
-       /**
-        * @param array|string $allowed
-        * @param array|string $disallowed
-        * @param array|string $values
-        * @test
-        * @dataProvider invalidInlineChildrenFilterParametersDataProvider
-        */
-       public function areInlineChildrenFilteredWithInvalidParameters($allowed, $disallowed, $values) {
-               $this->parameters = array(
-                       'allowedFileExtensions' => $allowed,
-                       'disallowedFileExtensions' => $disallowed,
-                       'values' => $values
-               );
-               $this->tceMainMock->expects($this->never())->method('deleteAction');
-               $this->fileFactoryMock->expects($this->never())->method('getFileReferenceObject');
-               $this->filter->filterInlineChildren($this->parameters, $this->tceMainMock);
-       }
-
-       /**
-        * @return array
-        */
-       public function invalidInlineChildrenFilterParametersDataProvider() {
-               return array(
-                       array(NULL, NULL, NULL),
-                       array('', '', array(0, '', NULL, FALSE)),
-                       array(NULL, NULL, array(0, '', NULL, FALSE))
-               );
-       }
-
-}
-
-?>
\ No newline at end of file
diff --git a/typo3/sysext/core/Tests/Unit/Resource/BaseTestCase.php b/typo3/sysext/core/Tests/Unit/Resource/BaseTestCase.php
new file mode 100644 (file)
index 0000000..5684317
--- /dev/null
@@ -0,0 +1,174 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Unit\Resource;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2011 Andreas Wolf <andreas.wolf@ikt-werk.de>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  A copy is found in the textfile GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Basic test case for the t3lib_file tests
+ *
+ * @author Andreas Wolf <andreas.wolf@ikt-werk.de>
+ * @package TYPO3
+ * @subpackage t3lib
+ */
+abstract class BaseTestCase extends \Tx_Phpunit_TestCase {
+
+       /**
+        * @var string
+        */
+       protected $basedir = 'basedir';
+
+       protected $mountDir;
+
+       protected $vfsContents = array();
+
+       public function setUp() {
+               $this->mountDir = uniqid('mount-');
+               $this->basedir = uniqid('base-');
+               \vfsStream::setup($this->basedir);
+               // Add an entry for the mount directory to the VFS contents
+               $this->vfsContents = array($this->mountDir => array());
+       }
+
+       protected function getMountRootUrl() {
+               return $this->getUrlInMount('');
+       }
+
+       protected function mergeToVfsContents($contents) {
+               $this->vfsContents = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($this->vfsContents, $contents);
+       }
+
+       protected function initializeVfs() {
+               if (is_callable('vfsStream::create') === FALSE) {
+                       $this->markTestSkipped('vfsStream::create() does not exist');
+               }
+               \vfsStream::create($this->vfsContents);
+       }
+
+       /**
+        * Adds the given directory structure to the mount folder in the VFS. Existing files will be overwritten!
+        *
+        * @param array $dirStructure
+        * @return void
+        */
+       protected function addToMount(array $dirStructure) {
+               $this->mergeToVfsContents(array($this->mountDir => $dirStructure));
+       }
+
+       /**
+        * Returns the URL for a path inside the mount directory
+        *
+        * @param $path
+        * @return string
+        */
+       protected function getUrlInMount($path) {
+               return \vfsStream::url(((($this->basedir . '/') . $this->mountDir) . '/') . ltrim($path, '/'));
+       }
+
+       /**
+        * Adds the given directory structure to the VFS. Existing files will be overwritten!
+        *
+        * @param array $dirStructure
+        * @return void
+        */
+       protected function addToVfs(array $dirStructure) {
+               $this->mergeToVfsContents($dirStructure);
+       }
+
+       /**
+        * Returns the URL for a path inside the VFS
+        *
+        * @param $path
+        * @return string
+        */
+       protected function getUrl($path) {
+               return \vfsStream::url(($this->basedir . '/') . ltrim($path, '/'));
+       }
+
+       /**
+        * Creates a file or folder mock. This should not be called directly, but only through getSimple{File,Folder}Mock()
+        *
+        * @param $type
+        * @param $identifier
+        * @param $mockedMethods
+        * @return \TYPO3\CMS\Core\Resource\File|\TYPO3\CMS\Core\Resource\Folder
+        */
+       protected function _createFileFolderMock($type, $identifier, $mockedMethods) {
+               if (!empty($mockedMethods)) {
+                       if (!in_array('getIdentifier', $mockedMethods)) {
+                               $mockedMethods[] = 'getIdentifier';
+                       }
+                       if (!in_array('getName', $mockedMethods)) {
+                               $mockedMethods[] = 'getName';
+                       }
+               }
+               $mock = $this->getMock($type, $mockedMethods, array(), '', FALSE);
+               $mock->expects($this->any())->method('getIdentifier')->will($this->returnValue($identifier));
+               $mock->expects($this->any())->method('getName')->will($this->returnValue(basename($identifier)));
+               return $mock;
+       }
+
+       /**
+        * Returns a simple mock of a file object that just knows its identifier
+        *
+        * @param string $identifier
+        * @param array $mockedMethods the methods to mock
+        * @return \TYPO3\CMS\Core\Resource\File
+        */
+       protected function getSimpleFileMock($identifier, $mockedMethods = array()) {
+               return $this->_createFileFolderMock('TYPO3\\CMS\\Core\\Resource\\File', $identifier, $mockedMethods);
+       }
+
+       /**
+        * Returns a simple mock of a file object that just knows its identifier
+        *
+        * @param string $identifier
+        * @param array $mockedMethods the methods to mock
+        * @return \TYPO3\CMS\Core\Resource\Folder
+        */
+       protected function getSimpleFolderMock($identifier, $mockedMethods = array()) {
+               return $this->_createFileFolderMock('TYPO3\\CMS\\Core\\Resource\\Folder', $identifier, $mockedMethods);
+       }
+
+       /**
+        * Returns a mock of a folder object with subfolders and files.
+        *
+        * @param $identifier
+        * @param array $mockedMethods Methods to mock, in addition to getFiles and getSubfolders
+        * @param \TYPO3\CMS\Core\Resource\Folder[] $subfolders
+        * @param \TYPO3\CMS\Core\Resource\File[] $files
+        * @return \TYPO3\CMS\Core\Resource\File|\TYPO3\CMS\Core\Resource\Folder
+        */
+       protected function getFolderMock($identifier, $mockedMethods = array(), $subfolders = array(), $files = array()) {
+               $folder = $this->_createFileFolderMock('TYPO3\\CMS\\Core\\Resource\\Folder', $identifier, array_merge($mockedMethods, array('getFiles', 'getSubfolders')));
+               $folder->expects($this->any())->method('getSubfolders')->will($this->returnValue($subfolders));
+               $folder->expects($this->any())->method('getFiles')->will($this->returnValue($files));
+               return $folder;
+       }
+
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/core/Tests/Unit/Resource/Driver/AbstractDriverTest.php b/typo3/sysext/core/Tests/Unit/Resource/Driver/AbstractDriverTest.php
new file mode 100644 (file)
index 0000000..f281f75
--- /dev/null
@@ -0,0 +1,131 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Unit\Resource\Driver;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2011-2012 Andreas Wolf <andreas.wolf@ikt-werk.de>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  A copy is found in the textfile GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+require_once dirname(__FILE__) . '/../BaseTestCase.php';
+
+/**
+ * Test case for the abstract driver.
+ *
+ * @author Andreas Wolf <andreas.wolf@ikt-werk.de>
+ * @package TYPO3
+ * @subpackage t3lib
+ */
+class AbstractDriverTest extends \TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCase {
+
+       /**
+        * @var \TYPO3\CMS\Core\Resource\Driver\AbstractDriver
+        */
+       protected $fixture;
+
+       /**
+        * @return \TYPO3\CMS\Core\Resource\Driver\AbstractDriver
+        */
+       protected function createDriverFixture() {
+               return $this->getMockForAbstractClass('TYPO3\\CMS\\Core\\Resource\\Driver\\AbstractDriver', array(), '', FALSE);
+       }
+
+       public function filenameValidationDataProvider() {
+               return array(
+                       'all-lowercase filename with extension' => array(
+                               'testfile.txt',
+                               TRUE
+                       ),
+                       'regular filename with mixed case and extension' => array(
+                               'someFilename.jpg',
+                               TRUE
+                       ),
+                       'filename with german umlauts' => array(
+                               'anÜmläütTestfile.jpg',
+                               TRUE
+                       ),
+                       'filename with double extension' => array(
+                               'someCompressedFile.tar.gz',
+                               TRUE
+                       ),
+                       'filename with dash' => array(
+                               'foo-bar',
+                               TRUE
+                       ),
+                       'filename with number' => array(
+                               'some23Number',
+                               TRUE
+                       ),
+                       'filename with whitespace' => array(
+                               'some whitespace',
+                               TRUE
+                       ),
+                       'filename with tab' => array(
+                               ('some' . TAB) . 'tag',
+                               TRUE
+                       ),
+                       'filename with carriage return' => array(
+                               ('some' . CR) . 'CarriageReturn',
+                               FALSE
+                       ),
+                       'filename with linefeed' => array(
+                               ('some' . LF) . 'Linefeed',
+                               FALSE
+                       ),
+                       'filename with leading slash' => array(
+                               '/invalidAsFilename',
+                               FALSE
+                       ),
+                       'filename with null character' => array(
+                               ('someFile' . chr(0)) . 'name',
+                               FALSE
+                       )
+               );
+       }
+
+       /**
+        * @test
+        * @dataProvider filenameValidationDataProvider
+        */
+       public function filenamesAreCorrectlyValidated($filename, $expectedResult) {
+               $fixture = $this->createDriverFixture(array());
+               $result = $fixture->isValidFilename($filename);
+               $this->assertEquals($expectedResult, $result);
+       }
+
+       /**
+        * @test
+        */
+       public function getFolderCorrectlySetsFolderName() {
+               $identifier = '/someFolder/someSubfolder/';
+               $fixture = $this->createDriverFixture(array());
+               $fixture->setStorage($this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE));
+               $mockedFactory = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceFactory');
+               $mockedFactory->expects($this->once())->method('createFolderObject')->with($this->anything(), $this->anything(), 'someSubfolder');
+               \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Resource\\ResourceFactory', $mockedFactory);
+               $fixture->getFolder($identifier);
+       }
+
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/core/Tests/Unit/Resource/Driver/DriverRegistryTest.php b/typo3/sysext/core/Tests/Unit/Resource/Driver/DriverRegistryTest.php
new file mode 100644 (file)
index 0000000..29abb74
--- /dev/null
@@ -0,0 +1,127 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Unit\Resource\Driver;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2011 Andreas Wolf <andreas.wolf@ikt-werk.de>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  A copy is found in the textfile GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Testcase for the FAL driver registry.
+ *
+ * @author Andreas Wolf <andreas.wolf@ikt-werk.de>
+ * @package TYPO3
+ * @subpackage t3lib
+ */
+class DriverRegistryTest extends \Tx_Phpunit_TestCase {
+
+       /**
+        * @var boolean Enable backup of global and system variables
+        */
+       protected $backupGlobals = TRUE;
+
+       /**
+        * Exclude TYPO3_DB from backup/ restore of $GLOBALS
+        * because resource types cannot be handled during serializing
+        *
+        * @var array
+        */
+       protected $backupGlobalsBlacklist = array('TYPO3_DB');
+
+       /**
+        * @var \TYPO3\CMS\Core\Resource\Driver\DriverRegistry
+        */
+       private $fixture;
+
+       public function setUp() {
+               $this->initializeFixture();
+       }
+
+       protected function initializeFixture() {
+               $this->fixture = new \TYPO3\CMS\Core\Resource\Driver\DriverRegistry();
+       }
+
+       /**
+        * @test
+        */
+       public function registeredDriverClassesCanBeRetrieved() {
+               $className = $this->getMockClass('TYPO3\\CMS\\Core\\Resource\\Driver\\AbstractDriver');
+               $this->fixture->registerDriverClass($className, 'foobar');
+               $returnedClassName = $this->fixture->getDriverClass('foobar');
+               $this->assertEquals($className, $returnedClassName);
+       }
+
+       /**
+        * @test
+        */
+       public function registerDriverClassThrowsExceptionIfClassDoesNotExist() {
+               $this->setExpectedException('InvalidArgumentException', '', 1314979197);
+               $this->fixture->registerDriverClass(uniqid());
+       }
+
+       /**
+        * @test
+        */
+       public function registerDriverClassThrowsExceptionIfShortnameIsAlreadyTaken() {
+               $this->setExpectedException('InvalidArgumentException', '', 1314979451);
+               $className = $this->getMockClass('TYPO3\\CMS\\Core\\Resource\\Driver\\AbstractDriver');
+               $this->fixture->registerDriverClass($className, 'foobar');
+               $this->fixture->registerDriverClass($className, 'foobar');
+       }
+
+       /**
+        * @test
+        */
+       public function getDriverClassThrowsExceptionIfClassIsNotRegistered() {
+               $this->setExpectedException('InvalidArgumentException', '', 1314085990);
+               $this->fixture->getDriverClass(uniqid());
+       }
+
+       /**
+        * @test
+        */
+       public function getDriverClassAcceptsClassNameIfClassIsRegistered() {
+               $className = $this->getMockClass('TYPO3\\CMS\\Core\\Resource\\Driver\\AbstractDriver');
+               $this->fixture->registerDriverClass($className, 'foobar');
+               $this->assertEquals($className, $this->fixture->getDriverClass($className));
+       }
+
+       /**
+        * @test
+        */
+       public function driverRegistryIsInitializedWithPreconfiguredDrivers() {
+               $className = $this->getMockClass('TYPO3\\CMS\\Core\\Resource\\Driver\\AbstractDriver');
+               $shortName = uniqid();
+               $GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['registeredDrivers'] = array(
+                       $shortName => array(
+                               'class' => $className
+                       )
+               );
+               $this->initializeFixture();
+               $this->assertEquals($className, $this->fixture->getDriverClass($shortName));
+       }
+
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/core/Tests/Unit/Resource/Driver/Fixtures/Dummy.html b/typo3/sysext/core/Tests/Unit/Resource/Driver/Fixtures/Dummy.html
new file mode 100644 (file)
index 0000000..e5825e8
--- /dev/null
@@ -0,0 +1,6 @@
+<html>
+       <head>
+       </head>
+       <body>
+       </body>
+</html>
\ No newline at end of file
diff --git a/typo3/sysext/core/Tests/Unit/Resource/Driver/Fixtures/LocalDriverFilenameFilter.php b/typo3/sysext/core/Tests/Unit/Resource/Driver/Fixtures/LocalDriverFilenameFilter.php
new file mode 100644 (file)
index 0000000..2cd2e2b
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Unit\Resource\Driver\Fixtures;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2012 Andreas Wolf <andreas.wolf@ikt-werk.de>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  A copy is found in the textfile GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Fixture class for the filename filters in the local driver.
+ */
+class LocalDriverFilenameFilter {
+
+       /**
+        * Filter filename
+        *
+        * @param string $itemName
+        * @param string $itemIdentifier
+        * @param string $parentIdentifier
+        * @param array $additionalInformation
+        * @param \TYPO3\CMS\Core\Resource\Driver\AbstractDriver $driverInstance
+        * @return boolean|integer
+        */
+       static public function filterFilename($itemName, $itemIdentifier, $parentIdentifier, array $additionalInformation, \TYPO3\CMS\Core\Resource\Driver\AbstractDriver $driverInstance) {
+               if ($itemName == 'fileA' || $itemName == 'folderA/') {
+                       return -1;
+               } else {
+                       return TRUE;
+               }
+       }
+
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/core/Tests/Unit/Resource/Driver/LocalDriverTest.php b/typo3/sysext/core/Tests/Unit/Resource/Driver/LocalDriverTest.php
new file mode 100644 (file)
index 0000000..e391bc5
--- /dev/null
@@ -0,0 +1,1538 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Unit\Resource\Driver;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2011 Andreas Wolf <andreas.wolf@ikt-werk.de>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  A copy is found in the textfile GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+require_once 'vfsStream/vfsStream.php';
+require_once dirname(dirname(__FILE__)) . '/BaseTestCase.php';
+require_once dirname(__FILE__) . '/Fixtures/LocalDriverFilenameFilter.php';
+
+/**
+ * Testcase for the local storage driver class of the TYPO3 VFS
+ *
+ * @package TYPO3
+ * @subpackage t3lib
+ * @author Andreas Wolf <andreas.wolf@ikt-werk.de>
+ */
+class LocalDriverTest extends \TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCase {
+
+       /**
+        * @var array
+        */
+       static private $testDirs = array();
+
+       public function setUp() {
+               parent::setUp();
+               // use a mocked file repository to avoid updating the index when doing property update tests
+               $mockedRepository = $this->getMock('TYPO3\\CMS\\Core\\Resource\\FileRepository');
+               \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Resource\\FileRepository', $mockedRepository);
+       }
+
+       public function tearDown() {
+               \TYPO3\CMS\Core\Utility\GeneralUtility::purgeInstances();
+               parent::tearDown();
+       }
+
+       static public function tearDownAfterClass() {
+               foreach (self::$testDirs as $dir) {
+                       \TYPO3\CMS\Core\Utility\GeneralUtility::rmdir($dir, TRUE);
+               }
+       }
+
+       /**
+        * Creates a "real" directory for doing tests. This is neccessary because some file system properties (e.g. permissions)
+        * cannot be reflected by vfsStream, and some methods (like touch()) don't work there either.
+        *
+        * Created directories are automatically destroyed by the tearDownAfterClass() method.
+        *
+        * @return string
+        */
+       protected function createRealTestdir() {
+               $basedir = PATH_site . 'typo3temp/' . uniqid('fal-test-');
+               mkdir($basedir);
+               self::$testDirs[] = $basedir;
+               return $basedir;
+       }
+
+       /**
+        * Create a "real" directory together with a driverFixture configured
+        * for this directory.
+        *
+        * @return array With path to base directory and driver fixture
+        */
+       protected function prepareRealTestEnvironment() {
+               $basedir = $this->createRealTestdir();
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $basedir
+               ));
+               return array($basedir, $fixture);
+       }
+
+       /**
+        * Creates a driver fixture object, optionally using a given mount object.
+        *
+        * IMPORTANT: Call this only after setting up the virtual file system (with the addTo* methods)!
+        *
+        * @param $driverConfiguration
+        * @param \TYPO3\CMS\Core\Resource\ResourceStorage $storageObject
+        * @param array $mockedDriverMethods
+        * @return \TYPO3\CMS\Core\Resource\Driver\LocalDriver
+        */
+       protected function createDriverFixture($driverConfiguration, \TYPO3\CMS\Core\Resource\ResourceStorage $storageObject = NULL, $mockedDriverMethods = array()) {
+               $this->initializeVfs();
+               if ($storageObject == NULL) {
+                       $storageObject = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
+               }
+               if (count($mockedDriverMethods) == 0) {
+                       $driver = new \TYPO3\CMS\Core\Resource\Driver\LocalDriver($driverConfiguration);
+               } else {
+                       $driver = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Driver\\LocalDriver', $mockedDriverMethods, array($driverConfiguration));
+               }
+               $storageObject->setDriver($driver);
+               $driver->setStorage($storageObject);
+               $driver->processConfiguration();
+               $driver->initialize();
+               return $driver;
+       }
+
+       /**
+        * @test
+        */
+       public function rootLevelFolderIsCreatedWithCorrectArguments() {
+               $mockedMount = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
+               $fixture = $this->createDriverFixture(array(), $mockedMount);
+               $mockedFactory = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceFactory');
+               $mockedFactory->expects($this->once())->method('createFolderObject')->with($this->equalTo($mockedMount), $this->equalTo('/'), $this->equalTo(''));
+               \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Resource\\ResourceFactory', $mockedFactory);
+               $fixture->getRootLevelFolder();
+               \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Resource\\ResourceFactory', new \TYPO3\CMS\Core\Resource\ResourceFactory());
+       }
+
+       /**
+        * @test
+        */
+       public function getDefaultFolderReturnsFolderForTemporaryPath() {
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               $folder = $fixture->getDefaultFolder();
+               $this->assertStringEndsWith('_temp_/', $folder->getIdentifier());
+       }
+
+       /**
+        * @test
+        */
+       public function defaultLevelFolderFolderIsCreatedIfItDoesntExist() {
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               $fixture->getDefaultFolder();
+               $this->assertFileExists($this->getUrlInMount('/_temp_/'));
+       }
+
+       /**
+        * @test
+        */
+       public function getFolderInFolderReturnsCorrectFolderObject() {
+               $this->addToMount(array(
+                       'someDir' => array(
+                               'someSubdir' => array()
+                       )
+               ));
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               $parentFolder = $fixture->getFolder('/someDir');
+               $folder = $fixture->getFolderInFolder('someSubdir', $parentFolder);
+               $this->assertEquals('/someDir/someSubdir/', $folder->getIdentifier());
+       }
+
+       /**
+        * @test
+        */
+       public function createFolderCreatesFolderOnDisk() {
+               $this->addToMount(array('some' => array('folder' => array())));
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               $mockedFolder = $this->getSimpleFolderMock('/some/folder/');
+               $fixture->createFolder('path', $mockedFolder);
+               $this->assertFileExists($this->getUrlInMount('/some/folder/'));
+               $this->assertFileExists($this->getUrlInMount('/some/folder/path'));
+       }
+
+       /**
+        * @test
+        */
+       public function createFolderReturnsFolderObject() {
+               $this->addToMount(array('some' => array('folder' => array())));
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               $mockedFolder = $this->getSimpleFolderMock('/some/folder/');
+               $createdFolder = $fixture->createFolder('path', $mockedFolder);
+               $this->assertEquals('/some/folder/path/', $createdFolder->getIdentifier());
+       }
+
+       public function createFolderSanitizesFolderNameBeforeCreationDataProvider() {
+               return array(
+                       'folder name with NULL character' => array(
+                               'some' . chr(0) . 'Folder',
+                               'some_Folder'
+                       ),
+                       'folder name with directory part' => array(
+                               '../someFolder',
+                               '.._someFolder'
+                       )
+               );
+       }
+
+       /**
+        * @test
+        * @dataProvider createFolderSanitizesFolderNameBeforeCreationDataProvider
+        */
+       public function createFolderSanitizesFolderNameBeforeCreation($newFolderName, $expectedFolderName) {
+               $this->addToMount(array('some' => array('folder' => array())));
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               $mockedFolder = $this->getSimpleFolderMock('/some/folder/');
+               $fixture->createFolder($newFolderName, $mockedFolder);
+               $this->assertFileExists($this->getUrlInMount('/some/folder/' . $expectedFolderName));
+       }
+
+       /**
+        * @test
+        */
+       public function driverConfigVerificationFailsIfConfiguredBasePathDoesNotExist() {
+               $this->setExpectedException('TYPO3\\CMS\\Core\\Resource\\Exception\\InvalidConfigurationException', '', 1299233097);
+               $driverConfiguration = array(
+                       'basePath' => \vfsStream::url($this->basedir . 'doesntexist/')
+               );
+               $this->assertFalse(file_exists($driverConfiguration['basePath']));
+               \TYPO3\CMS\Core\Resource\Driver\LocalDriver::verifyConfiguration($driverConfiguration);
+       }
+
+       /**
+        * @test
+        */
+       public function basePathIsNormalizedWithTrailingSlash() {
+               $driverConfiguration = array(
+                       'basePath' => $this->getMountRootUrl()
+               );
+               $fixture = $this->createDriverFixture($driverConfiguration);
+               $this->assertEquals('/', substr($fixture->getAbsoluteBasePath(), -1));
+       }
+
+       /**
+        * @test
+        */
+       public function noSecondSlashIsAddedIfBasePathAlreadyHasTrailingSlash() {
+               $driverConfiguration = array(
+                       'basePath' => $this->getMountRootUrl()
+               );
+               $fixture = $this->createDriverFixture($driverConfiguration);
+               $this->assertNotEquals('/', substr($fixture->getAbsoluteBasePath(), -2, 1));
+       }
+
+       /**
+        * @test
+        */
+       public function getAbsolutePathReturnsCorrectPath() {
+               $this->addToMount(array(
+                       'someFolder' => array(
+                               'file1.ext' => 'asdfg'
+                       )
+               ));
+               $mockedFile = $this->getSimpleFileMock('someFolder/file1.ext');
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               $path = $fixture->getAbsolutePath($mockedFile);
+               $this->assertTrue(file_exists($path));
+               $this->assertEquals($this->getUrlInMount('/someFolder/file1.ext'), $path);
+       }
+
+       /**
+        * @test
+        */
+       public function getLowLevelFileInfoReturnsCorrectFileSize() {
+               $contents = uniqid('foo');
+               $this->addToMount(array('file1.ext' => $contents));
+               $mockedFile = $this->getSimpleFileMock('file1.ext');
+               $fixture = $this->createDriverFixture(
+                       array('basePath' => $this->getMountRootUrl()),
+                       NULL,
+                               // Mocked because finfo() can not deal with vfs streams and throws warnings
+                       array('getMimeTypeOfFile')
+               );
+               $stat = $fixture->getLowLevelFileInfo($mockedFile);
+               $this->assertEquals(strlen($contents), $stat['size']);
+       }
+
+       /**
+        * @test
+        */
+       public function getLowLevelFileInfoReturnsCorrectFileCtime() {
+               $contents = uniqid('foo');
+               $this->addToMount(array('file1.ext' => $contents));
+               $mockedFile = $this->getSimpleFileMock('file1.ext');
+               $fixture = $this->createDriverFixture(
+                       array('basePath' => $this->getMountRootUrl()),
+                       NULL,
+                               // Mocked because finfo() can not deal with vfs streams and throws warnings
+                       array('getMimeTypeOfFile')
+               );
+               $path = $fixture->getAbsolutePath($mockedFile);
+               $stat = $fixture->getLowLevelFileInfo($mockedFile);
+               $this->assertEquals(filectime($path), $stat['ctime']);
+       }
+
+       /**
+        * @test
+        */
+       public function getLowLevelFileInfoReturnsCorrectFileMtime() {
+               $contents = uniqid('foo');
+               $this->addToMount(array('file1.ext' => $contents));
+               $mockedFile = $this->getSimpleFileMock('file1.ext');
+               $fixture = $this->createDriverFixture(
+                       array('basePath' => $this->getMountRootUrl()),
+                       NULL,
+                               // Mocked because finfo() can not deal with vfs streams and throws warnings
+                       array('getMimeTypeOfFile')
+               );
+               $path = $fixture->getAbsolutePath($mockedFile);
+               $stat = $fixture->getLowLevelFileInfo($mockedFile);
+               $this->assertEquals(fileatime($path), $stat['mtime']);
+       }
+
+       /**
+        * @test
+        */
+       public function getLowLevelFileInfoReturnsCorrectFileAtime() {
+               $contents = uniqid('foo');
+               $this->addToMount(array('file1.ext' => $contents));
+               $mockedFile = $this->getSimpleFileMock('file1.ext');
+               $fixture = $this->createDriverFixture(
+                       array('basePath' => $this->getMountRootUrl()),
+                       NULL,
+                               // Mocked because finfo() can not deal with vfs streams and throws warnings
+                       array('getMimeTypeOfFile')
+               );
+               $path = $fixture->getAbsolutePath($mockedFile);
+               $stat = $fixture->getLowLevelFileInfo($mockedFile);
+               $this->assertEquals(filemtime($path), $stat['atime']);
+       }
+
+       /**
+        * @test
+        */
+       public function getLowLevelFileInfoReturnsCorrectFileMimeType() {
+               $baseDir = $this->createRealTestdir();
+               /** @var $driverFixture \TYPO3\CMS\Core\Resource\Driver\LocalDriver */
+               $driverFixture = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Driver\\LocalDriver', array('getAbsolutePath'), array());
+               $fileMock = $this->getMock('TYPO3\\CMS\\Core\\Resource\\FileInterface');
+               copy(__DIR__ . '/Fixtures/Dummy.html', $baseDir . '/Dummy.html');
+               $driverFixture->expects($this->once())->method('getAbsolutePath')->will($this->returnValue($baseDir . '/Dummy.html'));
+               $stats = $driverFixture->getLowLevelFileInfo($fileMock);
+               $this->assertEquals('text/html', $stats['mimetype']);
+       }
+
+       /**
+        * @test
+        */
+       public function addFileMovesFileToCorrectLocation() {
+               $mockedFolder = $this->getSimpleFolderMock('/targetFolder/');
+               $this->addToMount(array('targetFolder' => array()));
+               $this->addToVfs(array(
+                       'sourceFolder' => array(
+                               'file' => 'asdf'
+                       )
+               ));
+               $fixture = $this->createDriverFixture(
+                       array('basePath' => $this->getMountRootUrl()),
+                       NULL,
+                               // Mocked because finfo() can not deal with vfs streams and throws warnings
+                       array('getMimeTypeOfFile')
+               );
+               $this->assertTrue(file_exists($this->getUrl('sourceFolder/file')));
+               $fixture->addFile($this->getUrl('sourceFolder/file'), $mockedFolder, 'file');
+               $this->assertTrue(file_exists($this->getUrlInMount('/targetFolder/file')));
+       }
+
+       /**
+        * @test
+        */
+       public function addFileUsesFilenameIfGiven() {
+               $mockedFolder = $this->getSimpleFolderMock('/targetFolder/');
+               $this->addToMount(array('targetFolder' => array()));
+               $this->addToVfs(array(
+                       'sourceFolder' => array(
+                               'file' => 'asdf'
+                       )
+               ));
+               $fixture = $this->createDriverFixture(
+                       array('basePath' => $this->getMountRootUrl()),
+                       NULL,
+                               // Mocked because finfo() can not deal with vfs streams and throws warnings
+                       array('getMimeTypeOfFile')
+               );
+               $this->assertTrue(file_exists($this->getUrl('sourceFolder/file')));
+               $fixture->addFile($this->getUrl('sourceFolder/file'), $mockedFolder, 'targetFile');
+               $this->assertTrue(file_exists($this->getUrlInMount('/targetFolder/targetFile')));
+       }
+
+       /**
+        * @test
+        */
+       public function addFileFailsIfFileIsInDriverStorage() {
+               $mockedFolder = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Folder', array(), array(), '', FALSE);
+               $mockedFolder->expects($this->any())->method('getIdentifier')->will($this->returnValue('/targetFolder/'));
+               $this->setExpectedException('InvalidArgumentException', '', 1314778269);
+               $this->addToMount(array(
+                       'targetFolder' => array(
+                               'file' => 'asdf'
+                       )
+               ));
+               $storageObject = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
+               $storageObject->expects($this->any())->method('getUid')->will($this->returnValue('1'));
+               $fixture = $this->createDriverFixture(
+                       array('basePath' => $this->getMountRootUrl()),
+                       $storageObject
+               );
+               $fixture->addFile($this->getUrlInMount('/targetFolder/file'), $mockedFolder, 'file');
+       }
+
+       /**
+        * @test
+        */
+       public function addFileReturnsFileObject() {
+               $mockedFolder = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Folder', array(), array(), '', FALSE);
+               $mockedFolder->expects($this->any())->method('getIdentifier')->will($this->returnValue('/targetFolder/'));
+               $this->addToMount(array('targetFolder' => array()));
+               $this->addToVfs(array(
+                       'sourceFolder' => array(
+                               'file' => 'asdf'
+                       )
+               ));
+               $fixture = $this->createDriverFixture(
+                       array('basePath' => $this->getMountRootUrl()),
+                       NULL,
+                               // Mocked because finfo() can not deal with vfs streams and throws warnings
+                       array('getMimeTypeOfFile')
+               );
+               $this->assertTrue(file_exists($this->getUrl('sourceFolder/file')));
+               $fileObject = $fixture->addFile($this->getUrl('sourceFolder/file'), $mockedFolder, 'file');
+               $this->assertInstanceOf('TYPO3\\CMS\\Core\\Resource\\File', $fileObject);
+               $this->assertEquals('file', $fileObject->getName());
+               $this->assertEquals('/targetFolder/file', $fileObject->getIdentifier());
+       }
+
+       /**
+        * @test
+        */
+       public function addFileRawCreatesCopyOfFile() {
+               $this->addToMount(array('targetFolder' => array()));
+               $this->addToVfs(array(
+                       'sourceFolder' => array(
+                               'file' => 'asdf'
+                       )
+               ));
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               $this->assertTrue(file_exists($this->getUrl('sourceFolder/file')));
+               $fileIdentifier = $fixture->addFileRaw($this->getUrl('sourceFolder/file'), $this->getSimpleFolderMock('/targetFolder/'), 'somefile');
+               $this->assertTrue(file_exists($this->getUrl('sourceFolder/file')));
+               $this->assertTrue(file_exists($this->getUrlInMount('targetFolder/somefile')));
+               $this->assertEquals('/targetFolder/somefile', $fileIdentifier);
+       }
+
+       /**
+        * @test
+        */
+       public function deleteFileRawRemovesFile() {
+               $this->addToMount(array(
+                       'targetFolder' => array(
+                               'file' => 'asdjlkfa'
+                       )
+               ));
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               $this->assertTrue(file_exists($this->getUrlInMount('targetFolder/file')));
+               $fixture->deleteFileRaw('/targetFolder/file');
+               $this->assertFalse(file_exists($this->getUrlInMount('targetFolder/file')));
+       }
+
+       /**
+        * @test
+        */
+       public function replacingFileUpdatesMetadataInFileObject() {
+               $this->addToMount(array(
+                       'targetFolder' => array(
+                               'file' => 'asdjlkfa'
+                       )
+               ));
+               $this->addToVfs(array(
+                       'sourceFolder' => array(
+                               'file' => 'asjdalks'
+                       )
+               ));
+               $fixture = $this->createDriverFixture(
+                       array('basePath' => $this->getMountRootUrl()),
+                       NULL,
+                               // Mocked because finfo() can not deal with vfs streams and throws warnings
+                       array('getMimeTypeOfFile')
+               );
+               $mockedFile = $this->getSimpleFileMock('/targetFolder/file', array('updateProperties'));
+               $mockedFile->expects($this->once())->method('updateProperties');
+               $fixture->replaceFile($mockedFile, $this->getUrl('sourceFolder/file'));
+       }
+
+       /**
+        * @test
+        */
+       public function existenceChecksWorkForFilesAndFolders() {
+               $this->addToMount(array(
+                       'file' => 'asdf',
+                       'folder' => array()
+               ));
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               // Using slashes at the beginning of paths because they will be stored in the DB this way.
+               $this->assertTrue($fixture->fileExists('/file'));
+               $this->assertTrue($fixture->folderExists('/folder/'));
+               $this->assertFalse($fixture->fileExists('/nonexistingFile'));
+               $this->assertFalse($fixture->folderExists('/nonexistingFolder/'));
+       }
+
+       /**
+        * @test
+        */
+       public function existenceChecksInFolderWorkForFilesAndFolders() {
+               $mockedFolder = $this->getSimpleFolderMock('/subfolder/');
+               $this->addToMount(array(
+                       'subfolder' => array(
+                               'file' => 'asdf',
+                               'folder' => array()
+                       )
+               ));
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               $this->assertTrue($fixture->fileExistsInFolder('file', $mockedFolder));
+               $this->assertTrue($fixture->folderExistsInFolder('folder', $mockedFolder));
+               $this->assertFalse($fixture->fileExistsInFolder('nonexistingFile', $mockedFolder));
+               $this->assertFalse($fixture->folderExistsInFolder('nonexistingFolder', $mockedFolder));
+       }
+
+       /**
+        * @test
+        */
+       public function getPublicUrlReturnsCorrectUriForConfiguredBaseUri() {
+               $baseUri = 'http://example.org/foobar/' . uniqid();
+               $this->addToMount(array(
+                       'file.ext' => 'asdf',
+                       'subfolder' => array(
+                               'file2.ext' => 'asdf'
+                       )
+               ));
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl(),
+                       'baseUri' => $baseUri
+               ));
+               $mockedFile1 = $this->getMock('TYPO3\\CMS\\Core\\Resource\\File', array(), array(), '', FALSE);
+               $mockedFile1->expects($this->any())->method('getIdentifier')->will($this->returnValue('/file.ext'));
+               $mockedFile2 = $this->getMock('TYPO3\\CMS\\Core\\Resource\\File', array(), array(), '', FALSE);
+               $mockedFile2->expects($this->any())->method('getIdentifier')->will($this->returnValue('/subfolder/file2.ext'));
+               $this->assertEquals($baseUri . '/file.ext', $fixture->getPublicUrl($mockedFile1));
+               $this->assertEquals($baseUri . '/subfolder/file2.ext', $fixture->getPublicUrl($mockedFile2));
+       }
+
+       /**
+        * @test
+        */
+       public function fileContentsCanBeWrittenAndRead() {
+               $fileContents = 'asdf';
+               $this->addToMount(array(
+                       'file.ext' => $fileContents
+               ));
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               $mockedFile = $this->getMock('TYPO3\\CMS\\Core\\Resource\\File', array(), array(), '', FALSE);
+               $mockedFile->expects($this->any())->method('getIdentifier')->will($this->returnValue('/file.ext'));
+               $this->assertEquals($fileContents, $fixture->getFileContents($mockedFile), 'File contents could not be read');
+               $newFileContents = 'asdfgh';
+               $fixture->setFileContents($mockedFile, $newFileContents);
+               $this->assertEquals($newFileContents, $fixture->getFileContents($mockedFile), 'New file contents could not be read.');
+       }
+
+       /**
+        * @test
+        */
+       public function setFileContentsReturnsNumberOfBytesWrittenToFile() {
+               $fileContents = 'asdf';
+               $this->addToMount(array(
+                       'file.ext' => $fileContents
+               ));
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               $mockedFile = $this->getSimpleFileMock('/file.ext');
+               $newFileContents = 'asdfgh';
+               $bytesWritten = $fixture->setFileContents($mockedFile, $newFileContents);
+               $this->assertEquals(strlen($newFileContents), $bytesWritten);
+       }
+
+       /**
+        * @test
+        * @depends existenceChecksWorkForFilesAndFolders
+        * @return array The driver fixture, the mocked file
+        */
+       public function newFilesCanBeCreated() {
+               $this->addToMount(array(
+                       'someDir' => array()
+               ));
+               /** @var $fixture \TYPO3\CMS\Core\Resource\Driver\LocalDriver */
+               list($basedir, $fixture) = $this->prepareRealTestEnvironment();
+               mkdir($basedir . '/someDir');
+               $fixture->createFile('testfile.txt', $fixture->getFolder('someDir'));
+               $mockedFile = $this->getSimpleFileMock('/someDir/testfile.txt');
+               $this->assertTrue($fixture->fileExists('/someDir/testfile.txt'));
+               return array($fixture, $mockedFile);
+       }
+
+       /**
+        * @test
+        * @depends newFilesCanBeCreated
+        */
+       public function createdFilesAreEmpty(array $arguments) {
+               /** @var $fixture \TYPO3\CMS\Core\Resource\Driver\LocalDriver */
+               list($fixture, $mockedFile) = $arguments;
+               $fileData = $fixture->getFileContents($mockedFile);
+               $this->assertEquals(0, strlen($fileData));
+       }
+
+       /**********************************
+        * File and directory listing
+        **********************************/
+       /**
+        * @test
+        */
+       public function getFileReturnsCorrectIdentifier() {
+               $this->addToMount(array(
+                       'someDir' => array(
+                               'someFile' => 'asdfg'
+                       ),
+                       'someFileAtRootLevel' => 'foobar'
+               ));
+               $fixture = $this->createDriverFixture(
+                       array('basePath' => $this->getMountRootUrl()),
+                       NULL,
+                               // Mocked because finfo() can not deal with vfs streams and throws warnings
+                       array('getMimeTypeOfFile')
+               );
+               $subdirFileInfo = $fixture->getFileInfoByIdentifier('/someDir/someFile');
+               $this->assertEquals('/someDir/someFile', $subdirFileInfo['identifier']);
+               $rootFileInfo = $fixture->getFileInfoByIdentifier('/someFileAtRootLevel');
+               $this->assertEquals('/someFileAtRootLevel', $rootFileInfo['identifier']);
+       }
+
+       /**
+        * @test
+        */
+       public function getFileThrowsExceptionIfFileDoesNotExist() {
+               $this->setExpectedException('InvalidArgumentException', '', 1314516809);
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               $fixture->getFileInfoByIdentifier('/some/file/at/a/random/path');
+       }
+
+       /**
+        * @test
+        */
+       public function getFileListReturnsEmptyArrayForEmptyDirectory() {
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               $fileList = $fixture->getFileList('/');
+               $this->assertEmpty($fileList);
+       }
+
+       /**
+        * @test
+        */
+       public function getFileListReturnsAllFilesInDirectory() {
+               $dirStructure = array(
+                       'aDir' => array(),
+                       'file1' => 'asdfg',
+                       'file2' => 'fdsa'
+               );
+               $this->addToMount($dirStructure);
+               $fixture = $this->createDriverFixture(
+                       array('basePath' => $this->getMountRootUrl()),
+                       NULL,
+                               // Mocked because finfo() can not deal with vfs streams and throws warnings
+                       array('getMimeTypeOfFile')
+               );
+               $fileList = $fixture->getFileList('/');
+               $this->assertEquals(array('file1', 'file2'), array_keys($fileList));
+       }
+
+       /**
+        * @test
+        */
+       public function getFileListFailsIfDirectoryDoesNotExist() {
+               $this->setExpectedException('InvalidArgumentException', '', 1314349666);
+               $this->addToMount(array('somefile' => ''));
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               $fixture->getFileList('somedir/');
+       }
+
+       /**
+        * @test
+        */
+       public function getFileListCallsConfiguredCallbackFunctionWithGivenItemName() {
+               $dirStructure = array(
+                       'file2' => 'fdsa'
+               );
+               // register static callback to self
+               $callback = array(
+                       array(
+                               get_class($this),
+                               'callbackStaticTestFunction'
+                       )
+               );
+               $this->addToMount($dirStructure);
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               // the callback function will throw an exception used to check if it was called with correct $itemName
+               $this->setExpectedException('InvalidArgumentException', '$itemName', 1336159604);
+               $fixture->getFileList('/', 0, 0, $callback);
+       }
+
+       /**
+        * Static callback function used to test if the filter callbacks work
+        * As it is static we are using an exception to test if it is really called and works
+        *
+        * @static
+        * @throws \InvalidArgumentException
+        * @see getFileListCallsConfiguredCallbackFunction
+        */
+       static public function callbackStaticTestFunction() {
+               list($itemName) = func_get_args();
+               if ($itemName === 'file2') {
+                       throw new \InvalidArgumentException('$itemName', 1336159604);
+               }
+       }
+
+       /**
+        * @test
+        */
+       public function getFileListFiltersItemsWithGivenFilterMethods() {
+               $dirStructure = array(
+                       'fileA' => 'asdfg',
+                       'fileB' => 'fdsa'
+               );
+               $this->addToMount($dirStructure);
+               $fixture = $this->createDriverFixture(
+                       array('basePath' => $this->getMountRootUrl()),
+                       NULL,
+                               // Mocked because finfo() can not deal with vfs streams and throws warnings
+                       array('getMimeTypeOfFile')
+               );
+               $filterCallbacks = array(
+                       array(
+                               'TYPO3\CMS\Core\Tests\Unit\Resource\Driver\Fixtures\LocalDriverFilenameFilter',
+                               'filterFilename',
+                       ),
+               );
+               $fileList = $fixture->getFileList('/', 0, 0, $filterCallbacks);
+               $this->assertNotContains('fileA', array_keys($fileList));
+       }
+
+       /**
+        * @test
+        */
+       public function getFolderListReturnsAllDirectoriesInDirectory() {
+               $dirStructure = array(
+                       'dir1' => array(),
+                       'dir2' => array(),
+                       'file' => 'asdfg'
+               );
+               $this->addToMount($dirStructure);
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               $fileList = $fixture->getFolderList('/');
+               $this->assertEquals(array('dir1', 'dir2'), array_keys($fileList));
+       }
+
+       /**
+        * @test
+        */
+       public function getFolderListDoesNotReturnHiddenFoldersByDefault() {
+               $dirStructure = array(
+                       '.someHiddenFile' => array(),
+                       'aDir' => array(),
+                       'file1' => ''
+               );
+               $this->addToMount($dirStructure);
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               $fileList = $fixture->getFolderList('/');
+               $this->assertEquals(array('aDir'), array_keys($fileList));
+       }
+
+       /**
+        * @test
+        */
+       public function getFolderListUsesCorrectPathForItems() {
+               $this->addToMount(array(
+                       'dir1' => array(
+                               'subdir1' => array()
+                       )
+               ));
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               $FolderList = $fixture->getFolderList('/');
+               $this->assertEquals('/dir1/', $FolderList['dir1']['identifier']);
+               $FolderList = $fixture->getFolderList('/dir1/');
+               $this->assertEquals('/dir1/subdir1/', $FolderList['subdir1']['identifier']);
+       }
+
+       /**
+        * Checks if the folder names . and .. are ignored when listing subdirectories
+        *
+        * @test
+        */
+       public function getFolderListLeavesOutNavigationalEntries() {
+               // we have to add .. and . manually, as these are not included in vfsStream directory listings (as opposed
+               // to normal file listings)
+               $this->addToMount(array(
+                       '..' => array(),
+                       '.' => array()
+               ));
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               $fileList = $fixture->getFolderList('/');
+               $this->assertEmpty($fileList);
+       }
+
+       /**
+        * @test
+        */
+       public function getFolderListFiltersItemsWithGivenFilterMethods() {
+               $dirStructure = array(
+                       'folderA' => array(),
+                       'folderB' => array()
+               );
+               $this->addToMount($dirStructure);
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               $filterCallbacks = array(
+                       array(
+                               'TYPO3\CMS\Core\Tests\Unit\Resource\Driver\Fixtures\LocalDriverFilenameFilter',
+                               'filterFilename',
+                       ),
+               );
+               $folderList = $fixture->getFolderList('/', 0, 0, $filterCallbacks);
+               $this->assertNotContains('folderA', array_keys($folderList));
+       }
+
+       /**
+        * @test
+        */
+       public function getFolderListFailsIfDirectoryDoesNotExist() {
+               $this->setExpectedException('InvalidArgumentException', '', 1314349666);
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               \vfsStream::create(array($this->basedir => array('somefile' => '')));
+               $fixture->getFolderList('somedir/');
+       }
+
+       /**
+        * @test
+        */
+       public function hashReturnsCorrectHashes() {
+               $contents = '68b329da9893e34099c7d8ad5cb9c940';
+               $expectedMd5Hash = '8c67dbaf0ba22f2e7fbc26413b86051b';
+               $expectedSha1Hash = 'a60cd808ba7a0bcfa37fa7f3fb5998e1b8dbcd9d';
+               $mockedFile = $this->getSimpleFileMock('/hashFile');
+               $this->addToMount(array('hashFile' => $contents));
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               $this->assertEquals($expectedSha1Hash, $fixture->hash($mockedFile, 'sha1'));
+               $this->assertEquals($expectedMd5Hash, $fixture->hash($mockedFile, 'md5'));
+       }
+
+       /**
+        * @test
+        */
+       public function hashingWithUnsupportedAlgorithmFails() {
+               $this->setExpectedException('InvalidArgumentException', '', 1304964032);
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               $fixture->hash($this->getSimpleFileMock('/hashFile'), uniqid());
+       }
+
+       /**
+        * @test
+        * @covers TYPO3\CMS\Core\Resource\Driver\LocalDriver::getFileForLocalProcessing
+        */
+       public function getFileForLocalProcessingCreatesCopyOfFileByDefault() {
+               $fileContents = 'asdfgh';
+               $this->addToMount(array(
+                       'someDir' => array(
+                               'someFile' => $fileContents
+                       )
+               ));
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ), NULL, array('copyFileToTemporaryPath'));
+               $mockedFile = $this->getSimpleFileMock('/someDir/someFile');
+               // TODO add parameter expectation for $mockedFile as soon as PHPUnit supports object identity matching in parameter expectations
+               $fixture->expects($this->once())->method('copyFileToTemporaryPath');
+               $fixture->getFileForLocalProcessing($mockedFile);
+       }
+
+       /**
+        * @test
+        */
+       public function getFileForLocalProcessingReturnsOriginalFilepathForReadonlyAccess() {
+               $fileContents = 'asdfgh';
+               $this->addToMount(array(
+                       'someDir' => array(
+                               'someFile' => $fileContents
+                       )
+               ));
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               $mockedFile = $this->getSimpleFileMock('/someDir/someFile');
+               $filePath = $fixture->getFileForLocalProcessing($mockedFile, FALSE);
+               $this->assertEquals($filePath, $this->getMountRootUrl() . 'someDir/someFile');
+       }
+
+       /**
+        * @test
+        */
+       public function filesCanBeCopiedToATemporaryPath() {
+               $fileContents = 'asdfgh';
+               $this->addToMount(array(
+                       'someDir' => array(
+                               'someFile' => $fileContents
+                       )
+               ));
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               $mockedFile = $this->getSimpleFileMock('/someDir/someFile');
+               $filePath = $fixture->copyFileToTemporaryPath($mockedFile);
+               $this->assertContains('/typo3temp/', $filePath);
+               $this->assertEquals($fileContents, file_get_contents($filePath));
+       }
+
+       /**
+        * @test
+        */
+       public function permissionsAreCorrectlyRetrievedForAllowedFile() {
+               /** @var $fixture \TYPO3\CMS\Core\Resource\Driver\LocalDriver */
+               list($basedir, $fixture) = $this->prepareRealTestEnvironment();
+               touch($basedir . '/someFile');
+               chmod($basedir . '/someFile', 448);
+               clearstatcache();
+               $this->assertEquals(array('r' => TRUE, 'w' => TRUE), $fixture->getFilePermissions($this->getSimpleFileMock('/someFile')));
+       }
+
+       /**
+        * @test
+        */
+       public function permissionsAreCorrectlyRetrievedForForbiddenFile() {
+               if (function_exists('posix_getegid') && posix_getegid() === 0) {
+                       $this->markTestSkipped('Test skipped if run on linux as root');
+               }
+               /** @var $fixture \TYPO3\CMS\Core\Resource\Driver\LocalDriver */
+               list($basedir, $fixture) = $this->prepareRealTestEnvironment();
+               touch($basedir . '/someForbiddenFile');
+               chmod($basedir . '/someForbiddenFile', 0);
+               clearstatcache();
+               $this->assertEquals(array('r' => FALSE, 'w' => FALSE), $fixture->getFilePermissions($this->getSimpleFileMock('/someForbiddenFile')));
+       }
+
+       /**
+        * @test
+        */
+       public function permissionsAreCorrectlyRetrievedForAllowedFolder() {
+               /** @var $fixture \TYPO3\CMS\Core\Resource\Driver\LocalDriver */
+               list($basedir, $fixture) = $this->prepareRealTestEnvironment();
+               mkdir($basedir . '/someFolder');
+               chmod($basedir . '/someFolder', 448);
+               clearstatcache();
+               $this->assertEquals(array('r' => TRUE, 'w' => TRUE), $fixture->getFolderPermissions($this->getSimpleFolderMock('/someFolder')));
+       }
+
+       /**
+        * @test
+        */
+       public function permissionsAreCorrectlyRetrievedForForbiddenFolder() {
+               if (function_exists('posix_getegid') && posix_getegid() === 0) {
+                       $this->markTestSkipped('Test skipped if run on linux as root');
+               }
+               /** @var $fixture \TYPO3\CMS\Core\Resource\Driver\LocalDriver */
+               list($basedir, $fixture) = $this->prepareRealTestEnvironment();
+               mkdir($basedir . '/someForbiddenFolder');
+               chmod($basedir . '/someForbiddenFolder', 0);
+               clearstatcache();
+               $this->assertEquals(array('r' => FALSE, 'w' => FALSE), $fixture->getFolderPermissions($this->getSimpleFolderMock('/someForbiddenFolder')));
+       }
+
+       /**
+        * Dataprovider for getFilePermissionsReturnsCorrectPermissionsForFilesNotOwnedByCurrentUser test
+        *
+        * @return array group, filemode and expected result
+        */
+       public function getFilePermissionsReturnsCorrectPermissionsForFilesNotOwnedByCurrentUser_dataProvider() {
+               $data = array();
+               // On some OS, the posix_* functions do not exits
+               if (function_exists('posix_getgid')) {
+                       $data = array(
+                               'current group, readable/writable' => array(
+                                       posix_getgid(),
+                                       48,
+                                       array('r' => TRUE, 'w' => TRUE)
+                               ),
+                               'current group, readable/not writable' => array(
+                                       posix_getgid(),
+                                       32,
+                                       array('r' => TRUE, 'w' => FALSE)
+                               ),
+                               'current group, not readable/not writable' => array(
+                                       posix_getgid(),
+                                       0,
+                                       array('r' => FALSE, 'w' => FALSE)
+                               )
+                       );
+               }
+               $data = array_merge_recursive($data, array(
+                       'arbitrary group, readable/writable' => array(
+                               \vfsStream::GROUP_USER_1,
+                               6,
+                               array('r' => TRUE, 'w' => TRUE)
+                       ),
+                       'arbitrary group, readable/not writable' => array(
+                               \vfsStream::GROUP_USER_1,
+                               436,
+                               array('r' => TRUE, 'w' => FALSE)
+                       ),
+                       'arbitrary group, not readable/not writable' => array(
+                               \vfsStream::GROUP_USER_1,
+                               432,
+                               array('r' => FALSE, 'w' => FALSE)
+                       )
+               ));
+               return $data;
+       }
+
+       /**
+        * @test
+        * @dataProvider getFilePermissionsReturnsCorrectPermissionsForFilesNotOwnedByCurrentUser_dataProvider
+        */
+       public function getFilePermissionsReturnsCorrectPermissionsForFilesNotOwnedByCurrentUser($group, $permissions, $expectedResult) {
+               $this->addToMount(array(
+                       'testfile' => 'asdfg'
+               ));
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               /** @var $fileObject vfsStreamContent */
+               $fileObject = \vfsStreamWrapper::getRoot()->getChild($this->mountDir)->getChild('testfile');
+               // just use an "arbitrary" user here - it is only important that
+               $fileObject->chown(\vfsStream::OWNER_USER_1);
+               $fileObject->chgrp($group);
+               $fileObject->chmod($permissions);
+               $this->assertEquals($expectedResult, $fixture->getFilePermissions($this->getSimpleFileMock('/testfile')));
+       }
+
+       /**
+        * @test
+        */
+       public function isWithinRecognizesFilesWithinFolderAndInOtherFolders() {
+               $mockedStorage = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
+               $mockedFolder = new \TYPO3\CMS\Core\Resource\Folder($mockedStorage, '/someFolder/', 'someFolder');
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ), $mockedStorage);
+               $this->assertTrue($fixture->isWithin($mockedFolder, '/someFolder/test.jpg'));
+               $this->assertTrue($fixture->isWithin($mockedFolder, '/someFolder/subFolder/test.jpg'));
+               $this->assertFalse($fixture->isWithin($mockedFolder, '/someFolderWithALongName/test.jpg'));
+       }
+
+       /**
+        * @test
+        */
+       public function isWithinAcceptsFileAndFolderObjectsAsContent() {
+               $mockedStorage = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
+               $mockedFolder = new \TYPO3\CMS\Core\Resource\Folder($mockedStorage, '/someFolder/', 'someFolder');
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ), $mockedStorage);
+               $mockedSubfolder = $this->getSimpleFolderMock('/someFolder/subfolder/');
+               $mockedFile = $this->getSimpleFileMock('/someFolder/test.jpg');
+               $this->assertTrue($fixture->isWithin($mockedFolder, $mockedFile));
+               $this->assertTrue($fixture->isWithin($mockedFolder, $mockedSubfolder));
+       }
+
+       /**
+        * @test
+        */
+       public function isWithinAlwaysReturnsFalseIfFolderIsWithinDifferentStorage() {
+               $mockedStorage1 = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
+               $mockedStorage2 = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
+               $mockedFolder = new \TYPO3\CMS\Core\Resource\Folder($mockedStorage1, '/someFolder/', 'someFolder');
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ), $mockedStorage2);
+               $fileIdentifier = '/someFolder/test.jpg';
+               $subfolderIdentifier = '/someFolder/subfolder/';
+               $mockedFile = $this->getSimpleFileMock($fileIdentifier);
+               $mockedSubfolder = $this->getSimpleFolderMock($subfolderIdentifier);
+               $this->assertFalse($fixture->isWithin($mockedFolder, $mockedFile));
+               $this->assertFalse($fixture->isWithin($mockedFolder, $fileIdentifier));
+               $this->assertFalse($fixture->isWithin($mockedFolder, $mockedSubfolder));
+               $this->assertFalse($fixture->isWithin($mockedFolder, $subfolderIdentifier));
+       }
+
+       /**********************************
+        * Copy/move file
+        **********************************/
+       /**
+        * @param $identifier
+        * @param null|\TYPO3\CMS\Core\Resource\ResourceStorage $storage
+        * @return \TYPO3\CMS\Core\Resource\File
+        */
+       protected function mockFileForCopyingAndMoving($identifier, \TYPO3\CMS\Core\Resource\ResourceStorage $storage = NULL) {
+               if (!$storage) {
+                       $storage = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
+               }
+               $fileObject = new \TYPO3\CMS\Core\Resource\File(array('identifier' => $identifier, 'name' => basename($identifier), 'storage' => $storage));
+               return $fileObject;
+       }
+
+       /**
+        * @param $identifier
+        * @param null|\TYPO3\CMS\Core\Resource\ResourceStorage $storage
+        * @return \TYPO3\CMS\Core\Resource\Folder
+        */
+       protected function mockFolderForCopyingAndMoving($identifier, \TYPO3\CMS\Core\Resource\ResourceStorage $storage = NULL) {
+               if (!$storage) {
+                       $storage = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
+               }
+               $folderObject = new \TYPO3\CMS\Core\Resource\Folder($storage, $identifier, basename($identifier), 0);
+               return $folderObject;
+       }
+
+       /**
+        * Prepares a simple two-folder environment with /someFolder/ and /targetFolder/. /someFolder contains a file with random
+        * contents
+        *
+        * @return array $mockedFolder, $sourceFolder, $fileContents, $fixture
+        */
+       protected function _prepareFolderEnvironmentForMoveTest() {
+               $mockedFolder = $this->getSimpleFolderMock('/targetFolder/');
+               $sourceFolder = $this->getSimpleFolderMock('/someFolder/');
+               $fileContents = uniqid();
+               $this->addToMount(array(
+                       'targetFolder' => array(),
+                       'someFolder' => array('file' => $fileContents)
+               ));
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               return array($mockedFolder, $sourceFolder, $fileContents, $fixture);
+       }
+
+       /**
+        * @test
+        */
+       public function filesCanBeCopiedWithinStorage() {
+               $fileContents = uniqid();
+               $this->addToMount(array(
+                       'someFile' => $fileContents,
+                       'targetFolder' => array()
+               ));
+               $fixture = $this->createDriverFixture(
+                       array('basePath' => $this->getMountRootUrl()),
+                       NULL,
+                               // Mocked because finfo() can not deal with vfs streams and throws warnings
+                       array('getMimeTypeOfFile')
+               );
+               $storage = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
+               $sourceFile = $this->mockFileForCopyingAndMoving('/someFile', $storage);
+               $targetFolder = $this->mockFolderForCopyingAndMoving('/targetFolder/', $storage);
+               $fixture->copyFileWithinStorage($sourceFile, $targetFolder, 'someFile');
+               $this->assertFileEquals($this->getUrlInMount('/someFile'), $this->getUrlInMount('/targetFolder/someFile'));
+       }
+
+       /**
+        * @test
+        */
+       public function filesCanBeMovedWithinStorage() {
+               $mockedFolder = $this->getSimpleFolderMock('/targetFolder/');
+               $storage = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
+               $sourceFile = $this->mockFileForCopyingAndMoving('/someFile', $storage);
+               $fileContents = uniqid();
+               $this->addToMount(array(
+                       'targetFolder' => array(),
+                       'someFile' => $fileContents
+               ));
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               $newIdentifier = $fixture->moveFileWithinStorage($sourceFile, $mockedFolder, 'file');
+               $this->assertEquals($fileContents, file_get_contents($this->getUrlInMount('/targetFolder/file')));
+               $this->assertFileNotExists($this->getUrlInMount('/someFile'));
+               $this->assertEquals('/targetFolder/file', $newIdentifier);
+       }
+
+       /**
+        * @test
+        */
+       public function fileMetadataIsChangedAfterMovingFile() {
+               $mockedFolder = $this->getSimpleFolderMock('/targetFolder/');
+               $storage = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
+               $sourceFile = $this->mockFileForCopyingAndMoving('/someFile', $storage);
+               $fileContents = uniqid();
+               $this->addToMount(array(
+                       'targetFolder' => array(),
+                       'someFile' => $fileContents
+               ));
+               $fixture = $this->createDriverFixture(
+                       array('basePath' => $this->getMountRootUrl()),
+                       NULL,
+                               // Mocked because finfo() can not deal with vfs streams and throws warnings
+                       array('getMimeTypeOfFile')
+               );
+               $newIdentifier = $fixture->moveFileWithinStorage($sourceFile, $mockedFolder, 'file');
+               $fileMetadata = $fixture->getFileInfoByIdentifier($newIdentifier);
+               $this->assertEquals($newIdentifier, $fileMetadata['identifier']);
+       }
+
+       public function renamingFiles_dataProvider() {
+               return array(
+                       'file in subfolder' => array(
+                               array(
+                                       'targetFolder' => array('file' => '')
+                               ),
+                               '/targetFolder/file',
+                               'newFile',
+                               '/targetFolder/newFile'
+                       ),
+                       'file in rootfolder' => array(
+                               array(
+                                       'fileInRoot' => ''
+                               ),
+                               '/fileInRoot',
+                               'newFile',
+                               '/newFile'
+                       )
+               );
+       }
+
+       /**
+        * @test
+        * @dataProvider renamingFiles_dataProvider
+        */
+       public function renamingFilesChangesFilenameOnDisk(array $filesystemStructure, $oldFileIdentifier, $newFileName, $expectedNewIdentifier) {
+               $this->addToMount($filesystemStructure);
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               $file = $this->getSimpleFileMock($oldFileIdentifier);
+               $newIdentifier = $fixture->renameFile($file, $newFileName);
+               $this->assertFalse($fixture->fileExists($oldFileIdentifier));
+               $this->assertTrue($fixture->fileExists($newIdentifier));
+               $this->assertEquals($expectedNewIdentifier, $newIdentifier);
+       }
+
+       /**
+        * @test
+        */
+       public function renamingFilesFailsIfTargetFileExists() {
+               $this->setExpectedException('TYPO3\\CMS\\Core\\Resource\\Exception\\ExistingTargetFileNameException', '', 1320291063);
+               $this->addToMount(array(
+                       'targetFolder' => array('file' => '', 'newFile' => '')
+               ));
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               $file = $this->getSimpleFileMock('/targetFolder/file');
+               $fixture->renameFile($file, 'newFile');
+       }
+
+       /**
+        * We use this data provider for testing move methods because there are some issues with the
+        *
+        * @return array
+        */
+       public function renamingFolders_dataProvider() {
+               return array(
+                       'folder in root folder' => array(
+                               array(
+                                       'someFolder' => array()
+                               ),
+                               '/someFolder/',
+                               'newFolder',
+                               '/newFolder/'
+                       ),
+                       'file in subfolder' => array(
+                               array(
+                                       'subfolder' => array(
+                                               'someFolder' => array()
+                                       )
+                               ),
+                               '/subfolder/someFolder/',
+                               'newFolder',
+                               '/subfolder/newFolder/'
+                       )
+               );
+       }
+
+       /**
+        * @test
+        * @dataProvider renamingFolders_dataProvider
+        */
+       public function renamingFoldersChangesFolderNameOnDisk(array $filesystemStructure, $oldFolderIdentifier, $newFolderName, $expectedNewIdentifier) {
+               $this->addToMount($filesystemStructure);
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               $mockedFolder = $this->getSimpleFolderMock($oldFolderIdentifier);
+               $mapping = $fixture->renameFolder($mockedFolder, $newFolderName);
+               $this->assertFalse($fixture->folderExists($oldFolderIdentifier));
+               $this->assertTrue($fixture->folderExists($expectedNewIdentifier));
+               $this->assertEquals($expectedNewIdentifier, $mapping[$oldFolderIdentifier]);
+       }
+
+       /**
+        * @test
+        */
+       public function renameFolderReturnsCorrectMappingInformationForAllFiles() {
+               $fileContents = 'asdfg';
+               $this->addToMount(array(
+                       'sourceFolder' => array(
+                               'subFolder' => array('file' => $fileContents),
+                               'file' => 'asdfg'
+                       )
+               ));
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               $sourceFolder = $this->getSimpleFolderMock('/sourceFolder/');
+               $mappingInformation = $fixture->renameFolder($sourceFolder, 'newFolder');
+               $this->assertEquals('/newFolder/', $mappingInformation['/sourceFolder/']);
+               $this->assertEquals('/newFolder/file', $mappingInformation['/sourceFolder/file']);
+               $this->assertEquals('/newFolder/subFolder/file', $mappingInformation['/sourceFolder/subFolder/file']);
+               $this->assertEquals('/newFolder/subFolder/', $mappingInformation['/sourceFolder/subFolder/']);
+       }
+
+       /**
+        * @test
+        */
+       public function renameFolderRevertsRenamingIfFilenameMapCannotBeCreated() {
+               $this->setExpectedException('RuntimeException', '', 1334160746);
+               $this->addToMount(array(
+                       'sourceFolder' => array(
+                               'file' => 'asdfg'
+                       )
+               ));
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ), NULL, array('createIdentifierMap'));
+               $fixture->expects($this->atLeastOnce())->method('createIdentifierMap')->will($this->throwException(new \TYPO3\CMS\Core\Resource\Exception\FileOperationErrorException()));
+               $sourceFolder = $this->getSimpleFolderMock('/sourceFolder/');
+               $fixture->renameFolder($sourceFolder, 'newFolder');
+               $this->assertFileExists($this->getUrlInMount('/sourceFolder/file'));
+       }
+
+       /**
+        * @test
+        */
+       public function isFolderEmptyReturnsTrueForEmptyFolder() {
+               // This also prepares the next few tests, so add more info than required for this test
+               $this->addToMount(array(
+                       'emptyFolder' => array()
+               ));
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               $mockedFolder = $this->getSimpleFolderMock('/emptyFolder/');
+               $this->assertTrue($fixture->isFolderEmpty($mockedFolder));
+               return $fixture;
+       }
+
+       /**
+        * @test
+        */
+       public function isFolderEmptyReturnsFalseIfFolderHasFile() {
+               $this->addToMount(array(
+                       'folderWithFile' => array(
+                               'someFile' => ''
+                       )
+               ));
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               $mockedFolder = $this->getSimpleFolderMock('/folderWithFile/');
+               $this->assertFalse($fixture->isFolderEmpty($mockedFolder));
+       }
+
+       /**
+        * @test
+        */
+       public function isFolderEmptyReturnsFalseIfFolderHasSubfolder() {
+               $this->addToMount(array(
+                       'folderWithSubfolder' => array(
+                               'someFolder' => array()
+                       )
+               ));
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               $mockedFolder = $this->getSimpleFolderMock('/folderWithSubfolder/');
+               $this->assertFalse($fixture->isFolderEmpty($mockedFolder));
+       }
+
+       /**********************************
+        * Copy/move folder
+        **********************************/
+       /**
+        * @test
+        */
+       public function foldersCanBeMovedWithinStorage() {
+               /** @var \TYPO3\CMS\Core\Resource\Driver\LocalDriver $fixture */
+               list($mockedFolder, $sourceFolder, $fileContents, $fixture) = $this->_prepareFolderEnvironmentForMoveTest();
+               $fixture->moveFolderWithinStorage($sourceFolder, $mockedFolder, 'someFolder');
+               $this->assertTrue(file_exists($this->getUrlInMount('/targetFolder/someFolder/')));
+               $this->assertEquals($fileContents, file_get_contents($this->getUrlInMount('/targetFolder/someFolder/file')));
+               $this->assertFileNotExists($this->getUrlInMount('/someFile'));
+       }
+
+       /**
+        * @test
+        */
+       public function moveFolderWithinStorageReturnsCorrectMappingInformationForAllFiles() {
+               $fileContents = 'asdfg';
+               $this->addToMount(array(
+                       'targetFolder' => array(),
+                       'sourceFolder' => array(
+                               'subFolder' => array('file' => $fileContents),
+                               'file' => 'asdfg'
+                       )
+               ));
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               $sourceFolder = $this->getSimpleFolderMock('/sourceFolder/');
+               $targetFolder = $this->getSimpleFolderMock('/targetFolder/');
+               $mappingInformation = $fixture->moveFolderWithinStorage($sourceFolder, $targetFolder, 'sourceFolder');
+               $this->assertEquals('/targetFolder/sourceFolder/file', $mappingInformation['/sourceFolder/file']);
+               $this->assertEquals('/targetFolder/sourceFolder/subFolder/file', $mappingInformation['/sourceFolder/subFolder/file']);
+               $this->assertEquals('/targetFolder/sourceFolder/subFolder/', $mappingInformation['/sourceFolder/subFolder/']);
+       }
+
+       /**
+        * @test
+        */
+       public function folderCanBeRenamedWhenMoving() {
+               /** @var \TYPO3\CMS\Core\Resource\Driver\LocalDriver $fixture */
+               list($mockedFolder, $sourceFolder, $fileContents, $fixture) = $this->_prepareFolderEnvironmentForMoveTest();
+               $fixture->moveFolderWithinStorage($sourceFolder, $mockedFolder, 'newFolder');
+               $this->assertTrue(file_exists($this->getUrlInMount('/targetFolder/newFolder/')));
+       }
+
+       protected function _setupFolderForCopyTest() {
+               $fileContents1 = uniqid();
+               $fileContents2 = uniqid();
+               $this->addToMount(array(
+                       'targetFolder' => array(),
+                       'sourceFolder' => array(
+                               'subFolder' => array('file' => $fileContents1),
+                               'file' => $fileContents2
+                       )
+               ));
+               $fixture = $this->createDriverFixture(array(
+                       'basePath' => $this->getMountRootUrl()
+               ));
+               return $fixture;
+       }
+
+       /**
+        * @test
+        * @see _setupFolderForCopyTest
+        */
+       public function foldersCanBeCopiedWithinSameStorage() {
+               $fixture = $this->_setupFolderForCopyTest();
+               $sourceFolder = $this->getSimpleFolderMock('/sourceFolder/');
+               $targetFolder = $this->getSimpleFolderMock('/targetFolder/');
+               $fixture->copyFolderWithinStorage($sourceFolder, $targetFolder, 'sourceFolder');
+               $this->assertTrue($fixture->folderExists('/targetFolder/sourceFolder/'));
+               $this->assertTrue($fixture->fileExists('/targetFolder/sourceFolder/file'));
+               $this->assertTrue($fixture->folderExists('/targetFolder/sourceFolder/subFolder/'));
+               $this->assertTrue($fixture->fileExists('/targetFolder/sourceFolder/subFolder/file'));
+       }
+
+       /**
+        * @test
+        * @see _setupFolderForCopyTest
+        */
+       public function folderNameCanBeChangedWhileCopying() {
+               $fixture = $this->_setupFolderForCopyTest();
+               $sourceFolder = $this->getSimpleFolderMock('/sourceFolder/');
+               $targetFolder = $this->getSimpleFolderMock('/targetFolder/');
+               $fixture->copyFolderWithinStorage($sourceFolder, $targetFolder, 'newFolder');
+               $this->assertTrue($fixture->folderExists('/targetFolder/newFolder/'));
+               $this->assertTrue($fixture->fileExists('/targetFolder/newFolder/file'));
+               $this->assertFalse($fixture->folderExists('/targetFolder/sourceFolder/'));
+       }
+
+}
+?>
diff --git a/typo3/sysext/core/Tests/Unit/Resource/FactoryTest.php b/typo3/sysext/core/Tests/Unit/Resource/FactoryTest.php
new file mode 100644 (file)
index 0000000..681b949
--- /dev/null
@@ -0,0 +1,92 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Unit\Resource;
+
+/***************************************************************
+ * Copyright notice
+ *
+ * (c) 2011 Andreas Wolf <andreas.wolf@ikt-werk.de>
+ * All rights reserved
+ *
+ * This script is part of the TYPO3 project. The TYPO3 project is
+ * free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * The GNU General Public License can be found at
+ * http://www.gnu.org/copyleft/gpl.html.
+ *
+ * This script is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+require_once 'vfsStream/vfsStream.php';
+
+/**
+ * Testcase for the factory of FAL
+ *
+ * @package TYPO3
+ * @subpackage t3lib
+ * @author Andreas Wolf <andreas.wolf@ikt-werk.de>
+ */
+class FactoryTest extends \Tx_Phpunit_TestCase {
+
+       /**
+        * @var \TYPO3\CMS\Core\Resource\ResourceFactory
+        */
+       private $fixture;
+
+       /**
+        * @var boolean
+        */
+       private $objectCreated = FALSE;
+
+       public function setUp() {
+               $this->fixture = new \TYPO3\CMS\Core\Resource\ResourceFactory();
+       }
+
+       protected function tearDown() {
+               \TYPO3\CMS\Core\Utility\GeneralUtility::purgeInstances();
+       }
+
+       /**********************************
+        * Storage Collections
+        **********************************/
+       /**
+        * @test
+        */
+       public function createStorageCollectionObjectCreatesCollectionWithCorrectArguments() {
+               $mockedMount = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
+               $path = uniqid();
+               $name = uniqid();
+               $storageCollection = $this->fixture->createFolderObject($mockedMount, $path, $name, 0);
+               $this->assertSame($mockedMount, $storageCollection->getStorage());
+               $this->assertEquals($path . '/', $storageCollection->getIdentifier());
+               $this->assertEquals($name, $storageCollection->getName());
+       }
+
+       /**********************************
+        * Drivers
+        **********************************/
+       /**
+        * @test
+        */
+       public function getDriverObjectAcceptsDriverClassName() {
+               $mockedDriver = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Driver\\AbstractDriver', array(), array(), '', FALSE);
+               $driverFixtureClass = get_class($mockedDriver);
+               \TYPO3\CMS\Core\Utility\GeneralUtility::addInstance($driverFixtureClass, $mockedDriver);
+               $mockedMount = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
+               $mockedRegistry = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Driver\\DriverRegistry');
+               $mockedRegistry->expects($this->once())->method('getDriverClass')->with($this->equalTo($driverFixtureClass))->will($this->returnValue($driverFixtureClass));
+               \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Resource\\Driver\\DriverRegistry', $mockedRegistry);
+               $obj = $this->fixture->getDriverObject($driverFixtureClass, array());
+               $this->assertInstanceOf('TYPO3\\CMS\\Core\\Resource\\Driver\\AbstractDriver', $obj);
+       }
+
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/core/Tests/Unit/Resource/FileTest.php b/typo3/sysext/core/Tests/Unit/Resource/FileTest.php
new file mode 100644 (file)
index 0000000..9e8a6c2
--- /dev/null
@@ -0,0 +1,355 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Unit\Resource;
+
+/***************************************************************
+ * Copyright notice
+ *
+ * (c) 2011 Andreas Wolf <andreas.wolf@ikt-werk.de>
+ * All rights reserved
+ *
+ * This script is part of the TYPO3 project. The TYPO3 project is
+ * free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * The GNU General Public License can be found at
+ * http://www.gnu.org/copyleft/gpl.html.
+ *
+ * This script is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+require_once 'vfsStream/vfsStream.php';
+
+/**
+ * Testcase for the file class of the TYPO3 FAL
+ *
+ * @package TYPO3
+ * @subpackage t3lib
+ * @author Andreas Wolf <andreas.wolf@ikt-werk.de>
+ * @todo Many, many, many tests are skipped in this test case...
+ */
+class FileTest extends \Tx_Phpunit_TestCase {
+
+       protected function tearDown() {
+               \TYPO3\CMS\Core\Utility\GeneralUtility::purgeInstances();
+       }
+
+       /**
+        * @return \TYPO3\CMS\Core\Resource\File
+        */
+       protected function prepareFixture() {
+               $fixture = new \TYPO3\CMS\Core\Resource\File('testfile');
+               return $fixture;
+       }
+
+       /**
+        * @test
+        * @todo Old code getAvailableProperties() needs to be replaced by current behaviour
+        */
+       public function propertiesPassedToConstructorAreAvailableViaGenericGetter() {
+               $this->markTestSkipped('TYPO3\\CMS\\Core\\Resource\\File::getAvailableProperties() does not exist');
+               $properties = array(
+                       uniqid() => uniqid(),
+                       uniqid() => uniqid(),
+                       'uid' => 1
+               );
+               $fixture = new \TYPO3\CMS\Core\Resource\File($properties);
+               $availablePropertiesBackup = \TYPO3\CMS\Core\Resource\File::getAvailableProperties();
+               \TYPO3\CMS\Core\Resource\File::setAvailableProperties(array_keys($properties));
+               foreach ($properties as $key => $value) {
+                       $this->assertTrue($fixture->hasProperty($key));
+                       $this->assertEquals($value, $fixture->getProperty($key));
+               }
+               $this->assertFalse($fixture->hasProperty(uniqid()));
+               \TYPO3\CMS\Core\Resource\File::setAvailableProperties($availablePropertiesBackup);
+               $this->setExpectedException('InvalidArgumentException', '', 1314226805);
+               $fixture->getProperty(uniqid());
+       }
+
+       /**
+        * @test
+        */
+       public function commonPropertiesAreAvailableWithOwnGetters() {
+               $properties = array(
+                       'name' => uniqid(),
+                       'storage' => $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE),
+                       'size' => 1024
+               );
+               $fixture = new \TYPO3\CMS\Core\Resource\File($properties);
+               foreach ($properties as $key => $value) {
+                       $this->assertEquals($value, call_user_func(array($fixture, 'get' . $key)));
+               }
+       }
+
+       /**
+        * @test
+        */
+       public function fileAsksRepositoryForIndexStatus() {
+               $mockedRepository = $this->getMock('TYPO3\\CMS\\Core\\Resource\\FileRepository');
+               $mockedRepository->expects($this->once())->method('getFileIndexRecord')->will($this->returnValue(array()));
+               \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Resource\\FileRepository', $mockedRepository);
+               $fixture = new \TYPO3\CMS\Core\Resource\File(array());
+               $this->assertTrue($fixture->isIndexed());
+       }
+
+       /**
+        * Tests if a file is seen as indexed if the record has a uid
+        *
+        * @test
+        */
+       public function fileIndexStatusIsTrueIfUidIsSet() {
+               $fixture = new \TYPO3\CMS\Core\Resource\File(array('uid' => 1));
+               $this->assertTrue($fixture->isIndexed());
+       }
+
+       /**
+        * @test
+        */
+       public function updatePropertiesUpdatesFileProperties() {
+               $identifier = '/' . uniqid();
+               $fixture = new \TYPO3\CMS\Core\Resource\File(array('uid' => 1, 'identifier' => '/test'));
+               $fixture->updateProperties(array('identifier' => $identifier));
+               $this->assertEquals($identifier, $fixture->getIdentifier());
+       }
+
+       /**
+        * @test
+        */
+       public function updatePropertiesLeavesPropertiesUntouchedIfNotSetInNewProperties() {
+               $fixture = new \TYPO3\CMS\Core\Resource\File(array('uid' => 1, 'foo' => 'asdf', 'identifier' => '/test'));
+               $fixture->updateProperties(array('foo' => 'foobar'));
+               $this->assertEquals('/test', $fixture->getIdentifier());
+               $this->assertEquals('/test', $fixture->getProperty('identifier'));
+       }
+
+       /**
+        * @test
+        */
+       public function updatePropertiesDiscardsUidIfAlreadySet() {
+               $fixture = new \TYPO3\CMS\Core\Resource\File(array('uid' => 1, 'identifier' => '/test'));
+               $fixture->updateProperties(array('uid' => 3));
+               $this->assertEquals(1, $fixture->getUid());
+       }
+
+       /**
+        * @test
+        */
+       public function updatePropertiesRecordsNamesOfChangedProperties() {
+               $fixture = new \TYPO3\CMS\Core\Resource\File(array('uid' => 1, 'foo' => 'asdf', 'baz' => 'fdsw', 'identifier' => '/test'));
+               $fixture->updateProperties(array('foo' => 'foobar', 'baz' => 'foobaz'));
+               $this->assertEquals(array('foo', 'baz'), $fixture->getUpdatedProperties());
+       }
+
+       /**
+        * @test
+        */
+       public function updatePropertiesDoesNotRecordPropertyNameIfSameValueIsProvided() {
+               $fixture = new \TYPO3\CMS\Core\Resource\File(array('uid' => 1, 'foo' => 'asdf', 'identifier' => '/test'));
+               $fixture->updateProperties(array('foo' => 'asdf'));
+               $this->assertEmpty($fixture->getUpdatedProperties());
+       }
+
+       /**
+        * @test
+        */
+       public function updatePropertiesMarksPropertyAsChangedOnlyOnce() {
+               $fixture = new \TYPO3\CMS\Core\Resource\File(array('uid' => 1, 'foo' => 'asdf', 'baz' => 'fdsw', 'identifier' => '/test'));
+               $fixture->updateProperties(array('foo' => 'foobar', 'baz' => 'foobaz'));
+               $fixture->updateProperties(array('foo' => 'fdsw', 'baz' => 'asdf'));
+               $this->assertEquals(array('foo', 'baz'), $fixture->getUpdatedProperties());
+       }
+
+       /**
+        * @test
+        */
+       public function updatePropertiesReloadsStorageObjectIfStorageChanges() {
+               $mockedNewStorage = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
+               $mockedOldStorage = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
+               $fixture = new \TYPO3\CMS\Core\Resource\File(array('uid' => 1, 'foo' => 'asdf', 'baz' => 'fdsw', 'identifier' => '/test', 'storage' => $mockedOldStorage));
+               $mockedRepository = $this->getMock('TYPO3\\CMS\\Core\\Resource\\StorageRepository');
+               $mockedRepository->expects($this->once())->method('findByUid')->with(2)->will($this->returnValue($mockedNewStorage));
+               \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Resource\\StorageRepository', $mockedRepository);
+               $fixture->updateProperties(array('storage' => 2));
+               $this->assertSame($mockedNewStorage, $fixture->getStorage());
+       }
+
+       /**
+        * @test
+        */
+       public function fetchingIndexedPropertyCausesFileObjectToLoadIndexRecord() {
+               $fixture = new \TYPO3\CMS\Core\Resource\File(array('identifier' => '/test', 'storage' => 1));
+               $mockedRepository = $this->getMock('TYPO3\\CMS\\Core\\Resource\\FileRepository');
+               $mockedRepository->expects($this->once())->method('getFileIndexRecord')->will($this->returnValue(array('uid' => 10)));
+               \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Resource\\FileRepository', $mockedRepository);
+               $this->assertEquals(10, $fixture->getProperty('uid'));
+       }
+
+       /**
+        * @test
+        */
+       public function isIndexedTriggersIndexingIfFileIsNotIndexedAlready() {
+               $fixture = new \TYPO3\CMS\Core\Resource\File(array('identifier' => '/test', 'storage' => 1));
+               $mockedRepository = $this->getMock('TYPO3\\CMS\\Core\\Resource\\FileRepository');
+               $mockedRepository->expects($this->once())->method('getFileIndexRecord')->will($this->returnValue(FALSE));
+               $mockedRepository->expects($this->once())->method('addToIndex')->will($this->returnValue(array('uid' => 10)));
+               \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Resource\\FileRepository', $mockedRepository);
+               $fixture->isIndexed();
+       }
+
+       /**
+        * @test
+        */
+       public function fileIsAutomaticallyIndexedOnPropertyAccessIfNotAlreadyIndexed() {
+               $fixture = new \TYPO3\CMS\Core\Resource\File(array('identifier' => '/test', 'storage' => 1));
+               $mockedRepository = $this->getMock('TYPO3\\CMS\\Core\\Resource\\FileRepository');
+               $mockedRepository->expects($this->once())->method('getFileIndexRecord')->will($this->returnValue(FALSE));
+               $mockedRepository->expects($this->once())->method('addToIndex')->will($this->returnValue(array('uid' => 10)));
+               \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Resource\\FileRepository', $mockedRepository);
+               $this->assertEquals(10, $fixture->getProperty('uid'));
+       }
+
+       /**
+        * @test
+        */
+       public function copyToCallsCopyOperationOnTargetFolderStorage() {
+               $targetStorage = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
+               $targetFolder = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Folder', array(), array(), '', FALSE);
+               $targetFolder->expects($this->any())->method('getStorage')->will($this->returnValue($targetStorage));
+               $fixture = new \TYPO3\CMS\Core\Resource\File(array());
+               $targetStorage->expects($this->once())->method('copyFile')->with($this->equalTo($fixture), $this->equalTo($targetFolder));
+               $fixture->copyTo($targetFolder);
+       }
+
+       /**
+        * @test
+        */
+       public function moveToCallsMoveOperationOnTargetFolderStorage() {
+               $targetStorage = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
+               $targetFolder = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Folder', array(), array(), '', FALSE);
+               $targetFolder->expects($this->any())->method('getStorage')->will($this->returnValue($targetStorage));
+               $fixture = new \TYPO3\CMS\Core\Resource\File(array());
+               $targetStorage->expects($this->once())->method('moveFile')->with($this->equalTo($fixture), $this->equalTo($targetFolder));
+               $fixture->moveTo($targetFolder);
+       }
+
+       /**
+        * @test
+        */
+       public function openCorrectlyOpensFileInDriver() {
+               $this->markTestSkipped();
+               $fixture = $this->prepareFixture();
+               $fileMode = 'invalidMode';
+               $mockDriver = $this->getMockForAbstractClass('t3lib_file_driver_Abstract');
+               $mockDriver->expects($this->atLeastOnce())->method('getFileHandle')->with($this->equalTo($fixture), $this->equalTo($fileMode));
+               $fixture->setStorageDriver($mockDriver);
+               $fixture->open($fileMode);
+       }
+
+       /**
+        * @test
+        */
+       public function isOpenReturnsCorrectValuesForClosedAndOpenFile() {
+               $this->markTestSkipped();
+               $fixture = $this->prepareFixture();
+               $fileMode = 'r';
+               $mockFileHandle = $this->getMock('TYPO3\\CMS\\Core\\Resource\\FileHandle', array(), array(), '', FALSE);
+               $mockFileHandle->expects($this->any())->method('isOpen')->will($this->returnValue(TRUE));
+               $mockDriver = $this->getMockForAbstractClass('t3lib_file_driver_Abstract');
+               $mockDriver->expects($this->any())->method('getFileHandle')->will($this->returnValue($mockFileHandle));
+               $fixture->setStorageDriver($mockDriver);
+               $this->assertFalse($fixture->isOpen());
+               $fixture->open($fileMode);
+               $this->assertTrue($fixture->isOpen());
+       }
+
+       /**
+        * @test
+        */
+       public function fileIsCorrectlyClosed() {
+               $this->markTestSkipped();
+               $fixture = $this->prepareFixture();
+               $fileMode = 'r';
+               $mockFileHandle = $this->getMock('TYPO3\\CMS\\Core\\Resource\\FileHandle', array(), array(), '', FALSE);
+               $mockFileHandle->expects($this->once())->method('close');
+               $mockDriver = $this->getMockForAbstractClass('t3lib_file_driver_Abstract');
+               $mockDriver->expects($this->any())->method('getFileHandle')->will($this->returnValue($mockFileHandle));
+               $fixture->setStorageDriver($mockDriver);
+               $fixture->open($fileMode);
+               $fixture->close();
+               $this->assertFalse($fixture->isOpen());
+       }
+
+       /**
+        * @test
+        */
+       public function readReturnsRequestedContentsFromDriver() {
+               $this->markTestSkipped();
+               $fixture = $this->prepareFixture();
+               $fileMode = 'r';
+               $fileContents = 'Some random file contents.';
+               $bytesToRead = 10;
+               $mockFileHandle = $this->getMock('TYPO3\\CMS\\Core\\Resource\\FileHandle', array(), array(), '', FALSE);
+               $mockFileHandle->expects($this->any())->method('isOpen')->will($this->returnValue(TRUE));
+               $mockDriver = $this->getMockForAbstractClass('t3lib_file_driver_Abstract');
+               $mockDriver->expects($this->any())->method('getFileHandle')->will($this->returnValue($mockFileHandle));
+               $mockDriver->expects($this->once())->method('readFromFile')->with($this->anything(), $this->equalTo($bytesToRead))->will($this->returnValue(substr($fileContents, 0, $bytesToRead)));
+               $fixture->setStorageDriver($mockDriver);
+               $fixture->open($fileMode);
+               $this->assertEquals(substr($fileContents, 0, $bytesToRead), $fixture->read($bytesToRead));
+       }
+
+       /**
+        * @test
+        */
+       public function readFailsIfFileIsClosed() {
+               $this->markTestSkipped();
+               $this->setExpectedException('RuntimeException', '', 1299863431);
+               $fixture = $this->prepareFixture();
+               $mockFileHandle = $this->getMock('TYPO3\\CMS\\Core\\Resource\\FileHandle', array(), array(), '', FALSE);
+               $mockDriver = $this->getMockForAbstractClass('t3lib_file_driver_Abstract');
+               $mockDriver->expects($this->any())->method('getFileHandle')->will($this->returnValue($mockFileHandle));
+               $fixture->setStorageDriver($mockDriver);
+               $fixture->read(1);
+       }
+
+       /**
+        * @test
+        */
+       public function writePassesContentsToDriver() {
+               $this->markTestSkipped();
+               $fixture = $this->prepareFixture();
+               $fileMode = 'r+';
+               $fileContents = 'Some random file contents.';
+               $mockFileHandle = $this->getMock('TYPO3\\CMS\\Core\\Resource\\FileHandle', array(), array(), '', FALSE);
+               $mockFileHandle->expects($this->any())->method('isOpen')->will($this->returnValue(TRUE));
+               $mockDriver = $this->getMockForAbstractClass('t3lib_file_driver_Abstract');
+               $mockDriver->expects($this->any())->method('getFileHandle')->will($this->returnValue($mockFileHandle));
+               $mockDriver->expects($this->once())->method('writeToFile')->with($this->anything(), $this->equalTo($fileContents))->will($this->returnValue(TRUE));
+               $fixture->setStorageDriver($mockDriver);
+               $fixture->open($fileMode);
+               $this->assertTrue($fixture->write($fileContents));
+       }
+
+       /**
+        * @test
+        */
+       public function writeFailsIfFileIsClosed() {
+               $this->markTestSkipped();
+               $this->setExpectedException('RuntimeException', '', 1299863432);
+               $fixture = $this->prepareFixture();
+               $mockFileHandle = $this->getMock('TYPO3\\CMS\\Core\\Resource\\FileHandle', array(), array(), '', FALSE);
+               $mockDriver = $this->getMockForAbstractClass('t3lib_file_driver_Abstract');
+               $mockDriver->expects($this->any())->method('getFileHandle')->will($this->returnValue($mockFileHandle));
+               $fixture->setStorageDriver($mockDriver);
+               $fixture->write('asdf');
+       }
+
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/core/Tests/Unit/Resource/FolderTest.php b/typo3/sysext/core/Tests/Unit/Resource/FolderTest.php
new file mode 100644 (file)
index 0000000..a4f35f6
--- /dev/null
@@ -0,0 +1,105 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Unit\Resource;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2011 Andreas Wolf <andreas.wolf@ikt-werk.de>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  A copy is found in the textfile GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+require_once 'vfsStream/vfsStream.php';
+
+/**
+ * Testcase for the storage collection class of the TYPO3 FAL
+ *
+ * @package TYPO3
+ * @subpackage t3lib
+ * @author Andreas Wolf <andreas.wolf@ikt-werk.de>
+ */
+class FolderTest extends \Tx_Phpunit_TestCase {
+
+       private $basedir = 'basedir';
+
+       public function setUp() {
+               \vfsStream::setup($this->basedir);
+       }
+
+       protected function tearDown() {
+               \TYPO3\CMS\Core\Utility\GeneralUtility::purgeInstances();
+       }
+
+       protected function createFolderFixture($path, $name, $mockedStorage = NULL) {
+               if ($mockedStorage === NULL) {
+                       $mockedStorage = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
+               }
+               return new \TYPO3\CMS\Core\Resource\Folder($mockedStorage, $path, $name, 0);
+       }
+
+       /**
+        * @test
+        */
+       public function constructorArgumentsAreAvailableAtRuntime() {
+               $path = uniqid();
+               $name = uniqid();
+               $mockedStorage = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
+               $fixture = $this->createFolderFixture($path, $name, $mockedStorage);
+               $this->assertSame($mockedStorage, $fixture->getStorage());
+               $this->assertStringStartsWith($path, $fixture->getIdentifier());
+               $this->assertEquals($name, $fixture->getName());
+       }
+
+       /**
+        * @test
+        */
+       public function propertiesCanBeUpdated() {
+               $fixture = $this->createFolderFixture('/somePath', 'someName');
+               $fixture->updateProperties(array('identifier' => '/someOtherPath', 'name' => 'someNewName'));
+               $this->assertEquals('someNewName', $fixture->getName());
+               $this->assertEquals('/someOtherPath', $fixture->getIdentifier());
+       }
+
+       /**
+        * @test
+        */
+       public function propertiesAreNotUpdatedIfNotSetInInput() {
+               $fixture = $this->createFolderFixture('/somePath/someName/', 'someName');
+               $fixture->updateProperties(array('identifier' => '/someOtherPath'));
+               $this->assertEquals('someName', $fixture->getName());
+       }
+
+       /**
+        * @test
+        */
+       public function getSubfolderCallsFactoryWithCorrectArguments() {
+               $mockedStorage = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
+               $mockedStorage->expects($this->once())->method('hasFolderInFolder')->with($this->equalTo('someSubfolder'))->will($this->returnValue(TRUE));
+               $mockedFactory = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceFactory');
+               $mockedFactory->expects($this->once())->method('createFolderObject')->with($mockedStorage, '/somePath/someFolder/someSubfolder/', 'someSubfolder');
+               \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Resource\\ResourceFactory', $mockedFactory);
+               $fixture = $this->createFolderFixture('/somePath/someFolder/', 'someFolder', $mockedStorage);
+               $fixture->getSubfolder('someSubfolder');
+       }
+
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/core/Tests/Unit/Resource/Repository/AbstractRepositoryTest.php b/typo3/sysext/core/Tests/Unit/Resource/Repository/AbstractRepositoryTest.php
new file mode 100644 (file)
index 0000000..894b7b6
--- /dev/null
@@ -0,0 +1,83 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Unit\Resource\Repository;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2011 Andreas Wolf <andreas.wolf@ikt-werk.de>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  A copy is found in the textfile GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Testcase for the abstract repository base class
+ *
+ * @author Andreas Wolf <andreas.wolf@ikt-werk.de>
+ * @package TYPO3
+ * @subpackage t3lib
+ */
+class AbstractRepositoryTest extends \Tx_Phpunit_TestCase {
+
+       /**
+        * @var \TYPO3\CMS\Core\Resource\AbstractRepository
+        */
+       private $fixture;
+
+       private $mockedDb;
+
+       private $Typo3DbBackup;
+
+       protected function createDatabaseMock() {
+               $this->mockedDb = $this->getMock('TYPO3\\CMS\\Core\\Database\\DatabaseConnection');
+               $this->Typo3DbBackup = $GLOBALS['TYPO3_DB'];
+               $GLOBALS['TYPO3_DB'] = $this->mockedDb;
+       }
+
+       public function setUp() {
+               $this->fixture = $this->getMockForAbstractClass('TYPO3\\CMS\\Core\\Resource\\AbstractRepository', array(), '', FALSE);
+       }
+
+       public function tearDown() {
+               if ($this->mockedDb) {
+                       $GLOBALS['TYPO3_DB'] = $this->Typo3DbBackup;
+               }
+       }
+
+       /**
+        * @test
+        */
+       public function findByUidFailsIfUidIsString() {
+               $this->setExpectedException('InvalidArgumentException', '', 1316779798);
+               $this->fixture->findByUid('asdf');
+       }
+
+       /**
+        * @test
+        */
+       public function findByUidAcceptsNumericUidInString() {
+               $this->createDatabaseMock();
+               $this->mockedDb->expects($this->once())->method('exec_SELECTgetSingleRow')->with($this->anything(), $this->anything(), $this->stringContains('uid=' . 123))->will($this->returnValue(array('uid' => 123)));
+               $this->fixture->findByUid('123');
+       }
+
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/core/Tests/Unit/Resource/Service/IndexerServiceTest.php b/typo3/sysext/core/Tests/Unit/Resource/Service/IndexerServiceTest.php
new file mode 100644 (file)
index 0000000..570a1e1
--- /dev/null
@@ -0,0 +1,109 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Unit\Resource\Service;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2011 Andreas Wolf <andreas.wolf@ikt-werk.de>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  A copy is found in the textfile GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Testcase for the file indexing service
+ *
+ * @author Andreas Wolf <andreas.wolf@ikt-werk.de>
+ * @package TYPO3
+ * @subpackage t3lib
+ */
+class IndexerServiceTest extends \Tx_Phpunit_TestCase {
+
+       /**
+        * @var boolean Backup all $GLOBALS
+        */
+       protected $backupGlobals = TRUE;
+
+       /**
+        * @var array Do not backup TYPO3_DB, it destroys the db resource
+        */
+       protected $backupGlobalsBlacklist = array('TYPO3_DB');
+
+       /**
+        * @var Store backup of TYPO3_DB
+        */
+       protected $dbBackup;
+
+       /**
+        * Set up this test case
+        */
+       public function setUp() {
+                       // Store TYPO3_DB in local var, it is substituted with a mock in this test
+               $this->dbBackup = $GLOBALS['TYPO3_DB'];
+       }
+
+       /**
+        * Tear down this test case
+        */
+       public function tearDown() {
+                       // Re constitute TYPO3_DB from backup
+               $GLOBALS['TYPO3_DB'] = $this->dbBackup;
+       }
+
+       /**
+        * @test
+        */
+       public function indexFileUpdatesFileProperties() {
+               $fileInfo = array(
+                       'mount' => 1,
+                       'identifier' => '/some/filepath/filename.jpg',
+                       'size' => 1234,
+                       'uid' => rand(1, 100)
+               );
+               /** @var $fixture \TYPO3\CMS\Core\Resource\Service\IndexerService */
+               $fixture = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Service\\IndexerService', array('gatherFileInformation'));
+               $fixture->expects($this->any())->method('gatherFileInformation')->will($this->returnValue($fileInfo));
+               $GLOBALS['TYPO3_DB'] = $this->getMock('TYPO3\\CMS\\Core\\Database\\DatabaseConnection', array(), array(), '', FALSE);
+               $GLOBALS['TYPO3_DB']->expects($this->atLeastOnce())->method('sql_insert_id')->will($this->returnValue($fileInfo['uid']));
+               $mockedFile = $this->getMock('TYPO3\\CMS\\Core\\Resource\\File', array(), array(), '', FALSE);
+               $mockedFile->expects($this->once())->method('updateProperties')->with($this->equalTo($fileInfo));
+               $fixture->indexFile($mockedFile);
+       }
+
+       /**
+        * @test
+        */
+       public function indexFileSetsCreationdateAndTimestampPropertiesOfRecordToCurrentExecutionTime() {
+               $fileInfo = array();
+               /** @var $fixture \TYPO3\CMS\Core\Resource\Service\IndexerService */
+               $fixture = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Service\\IndexerService', array('gatherFileInformation'));
+               $fixture->expects($this->any())->method('gatherFileInformation')->will($this->returnValue($fileInfo));
+               $GLOBALS['TYPO3_DB'] = $this->getMock('TYPO3\\CMS\\Core\\Database\\DatabaseConnection', array(), array(), '', FALSE);
+               $GLOBALS['TYPO3_DB']->expects($this->once())->method('exec_INSERTquery')->with($this->anything(), $this->equalTo(array(
+                       'crdate' => $GLOBALS['EXEC_TIME'],
+                       'tstamp' => $GLOBALS['EXEC_TIME']
+               )));
+               $mockedFile = $this->getMock('TYPO3\\CMS\\Core\\Resource\\File', array(), array(), '', FALSE);
+               $fixture->indexFile($mockedFile);
+       }
+
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/core/Tests/Unit/Resource/StorageTest.php b/typo3/sysext/core/Tests/Unit/Resource/StorageTest.php
new file mode 100644 (file)
index 0000000..6665ef6
--- /dev/null
@@ -0,0 +1,598 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Unit\Resource;
+
+/***************************************************************
+ * Copyright notice
+ *
+ * (c) 2011 Andreas Wolf <andreas.wolf@ikt-werk.de>
+ * All rights reserved
+ *
+ * This script is part of the TYPO3 project. The TYPO3 project is
+ * free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * The GNU General Public License can be found at
+ * http://www.gnu.org/copyleft/gpl.html.
+ *
+ * This script is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+require_once 'vfsStream/vfsStream.php';
+
+/**
+ * Testcase for the VFS mount class
+ *
+ * @package TYPO3
+ * @subpackage t3lib
+ * @author Andreas Wolf <andreas.wolf@ikt-werk.de>
+ */
+class StorageTest extends \TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCase {
+
+       /**
+        * @var \TYPO3\CMS\Core\Resource\ResourceStorage
+        */
+       private $fixture;
+
+       /**
+        * Prepare fixture
+        *
+        * @param array $configuration
+        * @param boolean $mockPermissionChecks
+        * @return void
+        */
+       protected function prepareFixture($configuration, $mockPermissionChecks = FALSE, $driverObject = NULL, array $storageRecord = array()) {
+               $permissionMethods = array('isFileActionAllowed', 'isFolderActionAllowed', 'checkFileActionPermission', 'checkUserActionPermission');
+               $mockedMethods = NULL;
+               $configuration = $this->convertConfigurationArrayToFlexformXml($configuration);
+               $storageRecord = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($storageRecord, array(
+                       'configuration' => $configuration
+               ));
+               if ($driverObject == NULL) {
+                       /** @var $mockedDriver \TYPO3\CMS\Core\Resource\Driver\AbstractDriver */
+                       $driverObject = $this->getMockForAbstractClass('TYPO3\\CMS\\Core\\Resource\\Driver\\AbstractDriver', array(), '', FALSE);
+               }
+               if ($mockPermissionChecks) {
+                       $mockedMethods = $permissionMethods;
+               }
+               if ($mockedMethods === NULL) {
+                       $this->fixture = new \TYPO3\CMS\Core\Resource\ResourceStorage($driverObject, $storageRecord);
+               } else {
+                       $this->fixture = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', $mockedMethods, array($driverObject, $storageRecord));
+                       foreach ($permissionMethods as $method) {
+                               $this->fixture->expects($this->any())->method($method)->will($this->returnValue(TRUE));
+                       }
+               }
+       }
+
+       /**
+        * Converts a simple configuration array into a FlexForm data structure serialized as XML
+        *
+        * @param array $configuration
+        * @return string
+        * @see t3lib_div::array2xml()
+        */
+       protected function convertConfigurationArrayToFlexformXml(array $configuration) {
+               $flexformArray = array('data' => array('sDEF' => array('lDEF' => array())));
+               foreach ($configuration as $key => $value) {
+                       $flexformArray['data']['sDEF']['lDEF'][$key] = array('vDEF' => $value);
+               }
+               $configuration = \TYPO3\CMS\Core\Utility\GeneralUtility::array2xml($flexformArray);
+               return $configuration;
+       }
+
+       /**
+        * Creates a driver fixture object, optionally using a given mount object.
+        *
+        * IMPORTANT: Call this only after setting up the virtual file system (with the addTo* methods)!
+        *
+        * @param $driverConfiguration
+        * @param \TYPO3\CMS\Core\Resource\ResourceStorage $storageObject
+        * @param array $mockedDriverMethods
+        * @return \TYPO3\CMS\Core\Resource\Driver\LocalDriver
+        */
+       protected function createDriverMock($driverConfiguration, \TYPO3\CMS\Core\Resource\ResourceStorage $storageObject = NULL, $mockedDriverMethods = array()) {
+               $this->initializeVfs();
+               if ($storageObject == NULL) {
+                       $storageObject = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
+               }
+               if ($mockedDriverMethods === NULL) {
+                       $driver = new \TYPO3\CMS\Core\Resource\Driver\LocalDriver($driverConfiguration);
+               } else {
+                               // We are using the LocalDriver here because PHPUnit can't mock concrete methods in abstract classes, so
+                               // when using the AbstractDriver we would be in trouble when wanting to mock away some concrete method
+                       $driver = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Driver\\LocalDriver', $mockedDriverMethods, array($driverConfiguration));
+               }
+               $storageObject->setDriver($driver);
+               $driver->setStorage($storageObject);
+               $driver->processConfiguration();
+               $driver->initialize();
+               return $driver;
+       }
+
+       /**
+        * @test
+        */
+       public function baseUriGetsSlashAppended() {
+               $uri = 'http://example.org/somewhere/else';
+               $this->prepareFixture(array('baseUri' => $uri));
+               $this->assertEquals($uri . '/', $this->fixture->getBaseUri());
+       }
+
+       public function capabilitiesDataProvider() {
+               return array(
+                       'only public' => array(
+                               array(
+                                       'public' => TRUE,
+                                       'writable' => FALSE,
+                                       'browsable' => FALSE
+                               )
+                       ),
+                       'only writable' => array(
+                               array(
+                                       'public' => FALSE,
+                                       'writable' => TRUE,
+                                       'browsable' => FALSE
+                               )
+                       ),
+                       'only browsable' => array(
+                               array(
+                                       'public' => FALSE,
+                                       'writable' => FALSE,
+                                       'browsable' => TRUE
+                               )
+                       ),
+                       'all capabilities' => array(
+                               array(
+                                       'public' => TRUE,
+                                       'writable' => TRUE,
+                                       'browsable' => TRUE
+                               )
+                       ),
+                       'none' => array(
+                               array(
+                                       'public' => FALSE,
+                                       'writable' => FALSE,
+                                       'browsable' => FALSE
+                               )
+                       )
+               );
+       }
+
+       /**
+        * @test
+        * @dataProvider capabilitiesDataProvider
+        */
+       public function capabilitiesOfStorageObjectAreCorrectlySet(array $capabilites) {
+               $storageRecord = array(
+                       'is_public' => $capabilites['public'],
+                       'is_writable' => $capabilites['writable'],
+                       'is_browsable' => $capabilites['browsable'],
+                       'is_online' => TRUE
+               );
+               $mockedDriver = $this->createDriverMock(array(), $this->fixture, array('hasCapability'));
+               $mockedDriver->expects($this->any())->method('hasCapability')->will($this->returnValue(TRUE));
+               $this->prepareFixture(array(), FALSE, $mockedDriver, $storageRecord);
+               $this->assertEquals($capabilites['public'], $this->fixture->isPublic(), 'Capability "public" is not correctly set.');
+               $this->assertEquals($capabilites['writable'], $this->fixture->isWritable(), 'Capability "writable" is not correctly set.');
+               $this->assertEquals($capabilites['browsable'], $this->fixture->isBrowsable(), 'Capability "browsable" is not correctly set.');
+       }
+
+       /**
+        * @test
+        */
+       public function fileAndFolderListFiltersAreInitializedWithDefaultFilters() {
+               $this->prepareFixture(array());
+               $this->assertEquals($GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['callbackFilterMethods'], $this->fixture->getFileAndFolderNameFilters());
+       }
+
+       /**
+        * @test
+        */
+       public function addFileFailsIfFileDoesNotExist() {
+               $mockedFolder = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Folder', array(), array(), '', FALSE);
+               $this->setExpectedException('InvalidArgumentException', '', 1319552745);
+               $this->prepareFixture(array());
+               $this->fixture->addFile('/some/random/file', $mockedFolder);
+       }
+
+       /**
+        * @test
+        */
+       public function addFileCallsDriverWithCorrectArguments() {
+               $mockedFolder = $this->getSimpleFolderMock('/targetFolder/');
+               $this->addToMount(array(
+                       'targetFolder' => array(),
+                       'file.ext' => 'ajslkd'
+               ));
+               $this->initializeVfs();
+               $localFilePath = $this->getUrlInMount('file.ext');
+               $this->prepareFixture(array());
+               /** @var $driver \TYPO3\CMS\Core\Resource\Driver\LocalDriver */
+               $driver = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Driver\\LocalDriver', array('addFile'), array(array('basePath' => $this->getUrlInMount('targetFolder/'))));
+               $driver->expects($this->once())->method('addFile')->with($this->equalTo($localFilePath), $this->anything(), $this->equalTo('file.ext'));
+               $this->fixture->setDriver($driver);
+               $this->fixture->addFile($localFilePath, $mockedFolder);
+       }
+
+       /**
+        * @test
+        */
+       public function addFileChangesFilenameIfFileExists() {
+               $mockedFolder = $this->getSimpleFolderMock('/');
+               $this->addToMount(array(
+                       'targetFolder' => array(
+                               'file.ext' => 'asdf',
+                               'file_01.ext' => 'asjdlkajs'
+                       ),
+                       'file.ext' => 'ajslkd'
+               ));
+               $this->initializeVfs();
+               $this->prepareFixture(array());
+               /** @var $driver \TYPO3\CMS\Core\Resource\Driver\LocalDriver */
+               $driver = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Driver\\LocalDriver', array('addFile', 'fileExistsInFolder'), array(array('basePath' => $this->getUrlInMount('targetFolder/'))));
+               $driver->expects($this->once())->method('addFile')->with($this->anything(), $this->anything(), $this->equalTo('file_02.ext'));
+               $driver->expects($this->exactly(3))->method('fileExistsInFolder')->will($this->onConsecutiveCalls($this->returnValue(TRUE), $this->returnValue(TRUE), $this->returnValue(FALSE)));
+               $this->fixture->setDriver($driver);
+               $this->fixture->addFile($this->getUrlInMount('file.ext'), $mockedFolder);
+       }
+
+       /**
+        * Data provider for checkFolderPermissionsRespectsFilesystemPermissions
+        *
+        * @return array
+        */
+       public function checkFolderPermissionsFilesystemPermissionsDataProvider() {
+               return array(
+                       'read action on readable/writable folder' => array(
+                               'read',
+                               array('r' => TRUE, 'w' => TRUE),
+                       ),
+                       'read action on unreadable folder' => array(
+                               'read',
+                               array('r' => FALSE, 'w' => TRUE),
+                               'TYPO3\\CMS\\Core\\Resource\\Exception\\InsufficientFolderReadPermissionsException'
+                       ),
+                       'write action on read-only folder' => array(
+                               'write',
+                               array('r' => TRUE, 'w' => FALSE),
+                               'TYPO3\\CMS\\Core\\Resource\\Exception\\InsufficientFolderWritePermissionsException'
+                       )
+               );
+       }
+
+       /**
+        * @test
+        * @dataProvider checkFolderPermissionsFilesystemPermissionsDataProvider
+        * @param string $action 'read' or 'write'
+        * @param array $permissionsFromDriver The permissions as returned from the driver
+        * @param boolean $expectedException
+        */
+       public function checkFolderPermissionsRespectsFilesystemPermissions($action, $permissionsFromDriver, $expectedException = '') {
+               $mockedDriver = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Driver\\LocalDriver');
+               $mockedDriver->expects($this->any())->method('getFolderPermissions')->will($this->returnValue($permissionsFromDriver));
+               $mockedFolder = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Folder', array(), array(), '', FALSE);
+                       // Let all other checks pass
+     &n