[TASK] Move last files from tests root folder
authorChristian Kuhn <lolli@schwarzbu.ch>
Tue, 11 Sep 2012 20:50:14 +0000 (22:50 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Tue, 11 Sep 2012 21:22:33 +0000 (23:22 +0200)
The patch moves the last files in tests/ to a different location:
* FAL functional StorageTest is moved to ext:core as functional test
* A naming mistake of one of the other FAL tests is fixed
* class.removexssTest.php and class.t3lib_formmailTest.php are moved
to ext:core/Tests/Legacy

Change-Id: I7f627c29f3154d07d40a3e11db3730f763f7ff2f
Resolves: #40841
Releases: 6.0
Reviewed-on: http://review.typo3.org/14530
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
t3lib/class.t3lib_formmail.php
tests/Functional/t3lib/file/StorageTest.php [deleted file]
tests/Unit/t3lib/class.t3lib_formmailTest.php [deleted file]
tests/Unit/typo3/contrib/class.removexssTest.php [deleted file]
typo3/sysext/core/Build/UnitTests.xml
typo3/sysext/core/Tests/Functional/Resource/ResourceStorageTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Legacy/t3lib/class.t3lib_formmailTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Legacy/typo3/contrib/class.removexssTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Resource/ResourceStorageTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Resource/StorageTest.php [deleted file]

index 87cfe10..28ac08e 100644 (file)
@@ -38,6 +38,7 @@
  * @package TYPO3
  * @subpackage t3lib
  * @see tslib_fe::sendFormmail(), t3lib/formmail.php
+ * @TODO: Deprecate this class
  */
 class t3lib_formmail {
 
diff --git a/tests/Functional/t3lib/file/StorageTest.php b/tests/Functional/t3lib/file/StorageTest.php
deleted file mode 100644 (file)
index 1e8bd12..0000000
+++ /dev/null
@@ -1,81 +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!
- ***************************************************************/
-require_once 'vfsStream/vfsStream.php';
-require_once realpath(dirname(__FILE__) . '/../../../Unit/t3lib/file/BaseTestCase.php');
-/**
- * Functional test case for the FAL Storage.
- *
- * @author Andreas Wolf <andreas.wolf@ikt-werk.de>
- * @package TYPO3
- * @subpackage t3lib
- */
-class t3lib_Tests_Functional_file_StorageTest extends t3lib_file_BaseTestCase {
-
-       /**
-        * @var \TYPO3\CMS\Core\Resource\ResourceStorage
-        */
-       protected $fixture;
-
-       protected function prepareFixture() {
-               $this->initializeVfs();
-               $driver = new \TYPO3\CMS\Core\Resource\Driver\LocalDriver(array('pathType' => 'absolute', 'basePath' => $this->getMountRootUrl()));
-               $driver->initialize();
-               $this->fixture = new \TYPO3\CMS\Core\Resource\ResourceStorage($driver, array());
-       }
-
-       /**
-        * Test if the default filters filter out hidden files (like .htaccess)
-        *
-        * @test
-        */
-       public function fileListingsDoNotContainHiddenFilesWithDefaultFilters() {
-               // we cannot use fixture->createFile() because touch() does not work with vfsStream
-               $this->addToMount(array('someFile' => '', '.someHiddenFile' => ''));
-               $this->prepareFixture();
-               $this->fixture->resetFileAndFolderNameFiltersToDefault();
-               $fileList = $this->fixture->getFileList('/');
-               $this->assertContains('someFile', array_keys($fileList));
-               $this->assertNotContains('.someHiddenFile', array_keys($fileList));
-       }
-
-       /**
-        * Test if the default filters filter out hidden folders (like .htaccess)
-        *
-        * @test
-        */
-       public function folderListingsDoNotContainHiddenFoldersByDefault() {
-               $this->addToMount(array('someFolder' => array(), '.someHiddenFolder' => array()));
-               $this->prepareFixture();
-               $this->fixture->resetFileAndFolderNameFiltersToDefault();
-               $folderList = $this->fixture->getFolderList('/');
-               $this->assertContains('someFolder', array_keys($folderList));
-               $this->assertNotContains('.someHiddenFolder', array_keys($folderList));
-       }
-
-}
-
-?>
\ No newline at end of file
diff --git a/tests/Unit/t3lib/class.t3lib_formmailTest.php b/tests/Unit/t3lib/class.t3lib_formmailTest.php
deleted file mode 100644 (file)
index d8d2476..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-<?php
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 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 t3lib_formmail
- *
- * @author Christian Kuhn <lolli@schwarzbu.ch>
- *
- * @package TYPO3
- * @subpackage t3lib
- */
-class t3lib_formmailTest extends tx_phpunit_testcase {
-
-       ///////////////////////////////
-       // tests concerning __destruct
-       ///////////////////////////////
-
-       /**
-        * Dataprovider for destructorDoesNotRemoveFilesNotWithinTypo3TempDirectory
-        */
-       public function invalidFileReferences() {
-               return array(
-                       'not within PATH_site' => array('/tmp/TYPO3-Formmail-Test'),
-                       'does not start with upload_temp_' => array(PATH_site . 'typo3temp/foo'),
-                       'directory traversal' => array(PATH_site . 'typo3temp/../typo3temp/upload_temp_foo'),
-               );
-       }
-
-       /**
-        * @test
-        * @dataProvider invalidFileReferences
-        */
-       public function destructorDoesNotRemoveFilesNotWithinTypo3TempDirectory($file) {
-               if (TYPO3_OS === 'WIN') {
-                       $this->markTestSkipped('destructorDoesNotRemoveFilesNotWithinTypo3TempDirectory() test not available on Windows.');
-               }
-                       // Reflection needs php 5.3.2 or above
-               if (version_compare(phpversion(), '5.3.2', '<')) {
-                       $this->markTestSkipped('destructorDoesNotRemoveFilesNotWithinTypo3TempDirectory() test not available with php version smaller than 5.3.2');
-               }
-
-                       // Create test file
-               touch($file);
-               if (!is_file($file)) {
-                       $this->markTestSkipped('destructorDoesNotRemoveFilesNotWithinTypo3TempDirectory() skipped: Test file could not be created');
-               }
-
-                       // Create t3lib_formmail instance, inject invalid file
-               $instance = new t3lib_formmail(999999999, $lockMethod);
-               $t3libLockReflection = new ReflectionClass('t3lib_formmail');
-               $t3libLockReflectionResourceProperty = $t3libLockReflection->getProperty('temporaryFiles');
-               $t3libLockReflectionResourceProperty->setAccessible(TRUE);
-               $t3libLockReflectionResourceProperty->setValue($instance, array($file));
-
-                       // Call release method
-               $instance->__destruct();
-
-                       // Check if file is still there and clean up
-               $fileExists = is_file($file);
-               if (is_file($file)) {
-                       unlink($file);
-               }
-
-               $this->assertTrue($fileExists);
-       }
-}
-?>
diff --git a/tests/Unit/typo3/contrib/class.removexssTest.php b/tests/Unit/typo3/contrib/class.removexssTest.php
deleted file mode 100644 (file)
index 083dce2..0000000
+++ /dev/null
@@ -1,450 +0,0 @@
-<?php
-/***************************************************************
-*  Copyright notice
-*
-*  (c) 2009-2011 Steffen Kamper <info@sk-typo3.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(PATH_typo3 . 'contrib/RemoveXSS/RemoveXSS.php');
-
-/**
- * Testcase for class RemoveXSS
- *
- * @author     Steffen Kamper <info@sk-typo3.de>
- * @package TYPO3
- * @subpackage contrib
- * @ see http://ha.ckers.org/xss.html
- * @ examples from http://ha.ckers.org/xssAttacks.xml
- */
-class RemoveXSSTest extends tx_phpunit_testcase {
-
-       /**
-        * @test
-        */
-       public function checkAttackScriptAlert() {
-               $testString = "<SCRIPT>alert('XSS')</SCRIPT>";
-               $expectedString = "<sc<x>ript>alert('XSS')</SCRIPT>";
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackScriptSrcJs() {
-               $testString = '<SCRIPT SRC=http://ha.ckers.org/xss.js></SCRIPT>';
-               $expectedString = "<sc<x>ript SRC=http://ha.ckers.org/xss.js></SCRIPT>";
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackScriptAlertFromCharCode() {
-               $testString = '<SCRIPT>alert(String.fromCharCode(88,83,83))</SCRIPT>';
-               $expectedString = '<sc<x>ript>alert(String.fromCharCode(88,83,83))</SCRIPT>';
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackBaseHref() {
-               $testString = "<BASE HREF=\"javascript:alert('XSS');//\">";
-               $expectedString = "<ba<x>se HREF=\"ja<x>vascript:alert('XSS');//\">";
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackBgsound() {
-               $testString = "<BGSOUND SRC=\"javascript:alert('XSS');\">";
-               $expectedString = "<bg<x>sound SRC=\"ja<x>vascript:alert('XSS');\">";
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackBodyBackground() {
-               $testString = "<BODY BACKGROUND=\"javascript:alert('XSS');\">";
-               $expectedString = "<BODY BACKGROUND=\"ja<x>vascript:alert('XSS');\">";
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackBodyOnLoad() {
-               $testString = "<BODY ONLOAD=alert('XSS')>";
-               $expectedString = "<BODY on<x>load=alert('XSS')>";
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackStyleUrl() {
-               $testString = "<DIV STYLE=\"background-image: url(javascript:alert('XSS'))\">";
-               $expectedString = "<DIV st<x>yle=\"background-image: url(ja<x>vascript:alert('XSS'))\">";
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackStyleWidth() {
-               $testString = "<DIV STYLE=\"width: expression(alert('XSS'));\">";
-               $expectedString = "<DIV st<x>yle=\"width: expression(alert('XSS'));\">";
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackFrameset() {
-               $testString = "<FRAMESET><FRAME SRC=\"javascript:alert('XSS');\"></FRAMESET>";
-               $expectedString = "<fr<x>ameset><fr<x>ame SRC=\"ja<x>vascript:alert('XSS');\"></FRAMESET>";
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackIframe() {
-               $testString = "<IFRAME SRC=\"javascript:alert('XSS');\"></IFRAME>";
-               $expectedString = "<if<x>rame SRC=\"ja<x>vascript:alert('XSS');\"></IFRAME>";
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackInputImage() {
-               $testString = "<INPUT TYPE=\"IMAGE\" SRC=\"javascript:alert('XSS');\">";
-               $expectedString = "<INPUT TYPE=\"IMAGE\" SRC=\"ja<x>vascript:alert('XSS');\">";
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackImageSrc() {
-               $testString = "<IMG SRC=\"javascript:alert('XSS');\">";
-               $expectedString = "<IMG SRC=\"ja<x>vascript:alert('XSS');\">";
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackImageSrcNoQuotesNoSemicolon() {
-               $testString = "<IMG SRC=javascript:alert('XSS')>";
-               $expectedString = "<IMG SRC=ja<x>vascript:alert('XSS')>";
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackImageDynsrc() {
-               $testString = "<IMG DYNSRC=\"javascript:alert('XSS');\">";
-               $expectedString = "<IMG DYNSRC=\"ja<x>vascript:alert('XSS');\">";
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackImageLowsrc() {
-               $testString = "<IMG LOWSRC=\"javascript:alert('XSS');\">";
-               $expectedString = "<IMG LOWSRC=\"ja<x>vascript:alert('XSS');\">";
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackStyle() {
-               $testString = "<STYLE>li {list-style-image: url(\"javascript:alert('XSS')\");}</STYLE>";
-               $expectedString = "<st<x>yle>li {list-style-image: url(\"ja<x>vascript:alert('XSS')\");}</STYLE>";
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackImageVbscript() {
-               $testString = "<IMG SRC='vbscript:msgbox(\"XSS\")'>";
-               $expectedString = "<IMG SRC='vb<x>script:msgbox(\"XSS\")'>";
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackLayer() {
-               $testString = "<LAYER SRC=\"http://ha.ckers.org/scriptlet.html\"></LAYER>";
-               $expectedString = "<la<x>yer SRC=\"http://ha.ckers.org/scriptlet.html\"></LAYER>";
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackMeta() {
-               $testString = '<META HTTP-EQUIV="refresh" CONTENT="0;url=javascript:alert(\'XSS\');">';
-               $expectedString = '<me<x>ta HTTP-EQUIV="refresh" CONTENT="0;url=ja<x>vascript:alert(\'XSS\');">';
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackMetaWithUrl() {
-               $testString = '<META HTTP-EQUIV="refresh" CONTENT="0;url=data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K">';
-               $expectedString = '<me<x>ta HTTP-EQUIV="refresh" CONTENT="0;url=data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K">';
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackMetaWithUrlExtended() {
-               $testString = '<META HTTP-EQUIV="refresh" CONTENT="0; URL=http://;URL=javascript:alert(\'XSS\');">';
-               $expectedString = '<me<x>ta HTTP-EQUIV="refresh" CONTENT="0; URL=http://;URL=ja<x>vascript:alert(\'XSS\');">';
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackObject() {
-               $testString = '<OBJECT TYPE="text/x-scriptlet" DATA="http://ha.ckers.org/scriptlet.html"></OBJECT>';
-               $expectedString = '<ob<x>ject TYPE="text/x-scriptlet" DATA="http://ha.ckers.org/scriptlet.html"></OBJECT>';
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackObjectEmbeddedXss() {
-               $testString = '<OBJECT classid=clsid:ae24fdae-03c6-11d1-8b76-0080c744f389><param name=url value=javascript:alert(\'XSS\')></OBJECT>';
-               $expectedString = '<ob<x>ject classid=clsid:ae24fdae-03c6-11d1-8b76-0080c744f389><param name=url value=ja<x>vascript:alert(\'XSS\')></OBJECT>';
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackEmbedFlash() {
-               $testString = '<EMBED SRC="http://ha.ckers.org/xss.swf" AllowScriptAccess="always"></EMBED>';
-               $expectedString = '<em<x>bed SRC="http://ha.ckers.org/xss.swf" AllowScriptAccess="always"></EMBED>';
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackActionScriptEval() {
-               $testString = 'a="get";b="URL("";c="javascript:";d="alert(\'XSS\');")";eval(a+b+c+d);";';
-               $expectedString = 'a="get";b="URL("";c="ja<x>vascript:";d="alert(\'XSS\');")";eval(a+b+c+d);";';
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackImageStyleWithComment() {
-               $testString = '<IMG STYLE="xss:expr/*XSS*/ession(alert(\'XSS\'))">';
-               $expectedString = '<IMG st<x>yle="xss:expr/*XSS*/ession(alert(\'XSS\'))">';
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackStyleInAnonymousHtml() {
-               $testString = '<XSS STYLE="xss:expression(alert(\'XSS\'))">';
-               $expectedString = '<XSS st<x>yle="xss:expression(alert(\'XSS\'))">';
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackStyleWithBackgroundImage() {
-               $testString = '<STYLE>.XSS{background-image:url("javascript:alert(\'XSS\')");}</STYLE><A CLASS=XSS></A>';
-               $expectedString = '<st<x>yle>.XSS{background-image:url("ja<x>vascript:alert(\'XSS\')");}</STYLE><A CLASS=XSS></A>';
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackStyleWithBackground() {
-               $testString = '<STYLE type="text/css">BODY{background:url("javascript:alert(\'XSS\')")}</STYLE>';
-               $expectedString = '<st<x>yle type="text/css">BODY{background:url("ja<x>vascript:alert(\'XSS\')")}</STYLE>';
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackStylesheet() {
-               $testString = '<LINK REL="stylesheet" HREF="javascript:alert(\'XSS\');">';
-               $expectedString = '<li<x>nk REL="stylesheet" HREF="ja<x>vascript:alert(\'XSS\');">';
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackRemoteStylesheet() {
-               $testString = '<LINK REL="stylesheet" HREF="http://ha.ckers.org/xss.css">';
-               $expectedString = '<li<x>nk REL="stylesheet" HREF="http://ha.ckers.org/xss.css">';
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackImportRemoteStylesheet() {
-               $testString = '<STYLE>@import\'http://ha.ckers.org/xss.css\';</STYLE>';
-               $expectedString = '<st<x>yle>@import\'http://ha.ckers.org/xss.css\';</STYLE>';
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-
-       /**
-        * @return array<array> input strings and expected output strings to test
-        *
-        * @see processWithDataProvider
-        */
-       public function processDataProvider() {
-               return array(
-                       'attackWithHexEncodedCharacter' => array(
-                               '<a href="j&#x61;vascript:alert(123);">click</a>',
-                               '<a href="ja<x>vascript:alert(123);">click</a>',
-                       ),
-                       'attackWithNestedHexEncodedCharacter' => array(
-                               '<a href="j&#x6&#x31;;vascript:alert(123);">click</a>',
-                               '<a href="ja<x>vascript:alert(123);">click</a>',
-                       ),
-                       'attackWithUnicodeNumericalEncodedCharacter' => array(
-                               '<a href="j&#x6&#x31;;vascript:alert(123);">click</a>',
-                               '<a href="ja<x>vascript:alert(123);">click</a>',
-                       ),
-                       'attackWithNestedUnicodeNumericalEncodedCharacter' => array(
-                               '<a href="j&#6&#53;;vascript:alert(123);">click</a>',
-                               '<a href="ja<x>vascript:alert(123);">click</a>',
-                       ),
-                       'attack with null character' => array(
-                               '<scr' . chr(0) . 'ipt></script>',
-                               '<sc<x>ript></script>'
-                       ),
-                       'attack with null character in attribute' => array(
-                               '<a href="j' . chr(0) . 'avascript:alert(123);"></a>',
-                               '<a href="ja<x>vascript:alert(123);"></a>'
-                       ),
-               );
-       }
-
-       /**
-        * @test
-        *
-        * @param string $input input value to test
-        * @param string $expected expected output value
-        *
-        * @dataProvider processDataProvider
-        */
-       public function processWithDataProvider($input, $expected) {
-               $this->assertEquals(
-                       $expected,
-                       RemoveXSS::process($input)
-               );
-       }
-
-       /**
-        * Allowed combinations
-        */
-       public function processValidDataProvider() {
-               return array(
-                       'multibyte characters' => array(
-                               '<img®€ÜüÖöÄä></img>',
-                       ),
-                       'tab' => array(
-                               '<im' . chr(9) . 'g></img>',
-                       ),
-                       'line feed' => array(
-                               '<im' . chr(10) . 'g></img>',
-                       ),
-                       'carriage return' => array(
-                               '<im' . chr(13) . 'g></img>',
-                       ),
-               );
-       }
-
-       /**
-        * @test
-        * @param string $input Value to test
-        * @dataProvider processValidDataProvider
-        */
-       public function proccessValidStrings($input) {
-               $this->assertEquals(
-                       $input,
-                       RemoveXSS::process($input)
-               );
-       }
-}
-?>
\ No newline at end of file
index 9a2df9a..ad5cd00 100644 (file)
@@ -22,8 +22,8 @@
                <testsuite name="EXT:frontend tests">
                        <directory>../../../../typo3/sysext/frontend/Tests/Unit/</directory>
                </testsuite>
-               <testsuite name="Core tests">
-                       <directory>../../../../tests/Unit/</directory>
+               <testsuite name="Core legacy tests">
+                       <directory>../../../../typo3/sysext/core/Tests/Legacy/</directory>
                </testsuite>
                <testsuite name="EXT:beuser tests">
                        <directory>../../../../typo3/sysext/beuser/Tests/Unit/</directory>
diff --git a/typo3/sysext/core/Tests/Functional/Resource/ResourceStorageTest.php b/typo3/sysext/core/Tests/Functional/Resource/ResourceStorageTest.php
new file mode 100644 (file)
index 0000000..1bd98a1
--- /dev/null
@@ -0,0 +1,84 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Functional\Resource;
+
+/***************************************************************
+ *  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!
+ ***************************************************************/
+
+require_once 'vfsStream/vfsStream.php';
+
+/**
+ * Functional test case for the FAL Storage.
+ *
+ * @author Andreas Wolf <andreas.wolf@ikt-werk.de>
+ * @package TYPO3
+ * @subpackage t3lib
+ */
+class ResourceStorageTest extends \TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCase {
+
+       /**
+        * @var \TYPO3\CMS\Core\Resource\ResourceStorage
+        */
+       protected $fixture;
+
+       protected function prepareFixture() {
+               $this->initializeVfs();
+               $driver = new \TYPO3\CMS\Core\Resource\Driver\LocalDriver(array('pathType' => 'absolute', 'basePath' => $this->getMountRootUrl()));
+               $driver->initialize();
+               $this->fixture = new \TYPO3\CMS\Core\Resource\ResourceStorage($driver, array());
+       }
+
+       /**
+        * Test if the default filters filter out hidden files (like .htaccess)
+        *
+        * @test
+        */
+       public function fileListingsDoNotContainHiddenFilesWithDefaultFilters() {
+               // we cannot use fixture->createFile() because touch() does not work with vfsStream
+               $this->addToMount(array('someFile' => '', '.someHiddenFile' => ''));
+               $this->prepareFixture();
+               $this->fixture->resetFileAndFolderNameFiltersToDefault();
+               $fileList = $this->fixture->getFileList('/');
+               $this->assertContains('someFile', array_keys($fileList));
+               $this->assertNotContains('.someHiddenFile', array_keys($fileList));
+       }
+
+       /**
+        * Test if the default filters filter out hidden folders (like .htaccess)
+        *
+        * @test
+        */
+       public function folderListingsDoNotContainHiddenFoldersByDefault() {
+               $this->addToMount(array('someFolder' => array(), '.someHiddenFolder' => array()));
+               $this->prepareFixture();
+               $this->fixture->resetFileAndFolderNameFiltersToDefault();
+               $folderList = $this->fixture->getFolderList('/');
+               $this->assertContains('someFolder', array_keys($folderList));
+               $this->assertNotContains('.someHiddenFolder', array_keys($folderList));
+       }
+
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/core/Tests/Legacy/t3lib/class.t3lib_formmailTest.php b/typo3/sysext/core/Tests/Legacy/t3lib/class.t3lib_formmailTest.php
new file mode 100644 (file)
index 0000000..116f2e9
--- /dev/null
@@ -0,0 +1,90 @@
+<?php
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 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 t3lib_formmail
+ *
+ * This legacy test will be removed if t3lib_formmail is removed
+ *
+ * @author Christian Kuhn <lolli@schwarzbu.ch>
+ *
+ * @package TYPO3
+ * @subpackage t3lib
+ */
+class t3lib_formmailTest extends tx_phpunit_testcase {
+
+       ///////////////////////////////
+       // tests concerning __destruct
+       ///////////////////////////////
+
+       /**
+        * Dataprovider for destructorDoesNotRemoveFilesNotWithinTypo3TempDirectory
+        */
+       public function invalidFileReferences() {
+               return array(
+                       'not within PATH_site' => array('/tmp/TYPO3-Formmail-Test'),
+                       'does not start with upload_temp_' => array(PATH_site . 'typo3temp/foo'),
+                       'directory traversal' => array(PATH_site . 'typo3temp/../typo3temp/upload_temp_foo'),
+               );
+       }
+
+       /**
+        * @test
+        * @dataProvider invalidFileReferences
+        */
+       public function destructorDoesNotRemoveFilesNotWithinTypo3TempDirectory($file) {
+               if (TYPO3_OS === 'WIN') {
+                       $this->markTestSkipped('destructorDoesNotRemoveFilesNotWithinTypo3TempDirectory() test not available on Windows.');
+               }
+                       // Reflection needs php 5.3.2 or above
+               if (version_compare(phpversion(), '5.3.2', '<')) {
+                       $this->markTestSkipped('destructorDoesNotRemoveFilesNotWithinTypo3TempDirectory() test not available with php version smaller than 5.3.2');
+               }
+
+                       // Create test file
+               touch($file);
+               if (!is_file($file)) {
+                       $this->markTestSkipped('destructorDoesNotRemoveFilesNotWithinTypo3TempDirectory() skipped: Test file could not be created');
+               }
+
+                       // Create t3lib_formmail instance, inject invalid file
+               $instance = new t3lib_formmail(999999999, $lockMethod);
+               $t3libLockReflection = new ReflectionClass('t3lib_formmail');
+               $t3libLockReflectionResourceProperty = $t3libLockReflection->getProperty('temporaryFiles');
+               $t3libLockReflectionResourceProperty->setAccessible(TRUE);
+               $t3libLockReflectionResourceProperty->setValue($instance, array($file));
+
+                       // Call release method
+               $instance->__destruct();
+
+                       // Check if file is still there and clean up
+               $fileExists = is_file($file);
+               if (is_file($file)) {
+                       unlink($file);
+               }
+
+               $this->assertTrue($fileExists);
+       }
+}
+?>
diff --git a/typo3/sysext/core/Tests/Legacy/typo3/contrib/class.removexssTest.php b/typo3/sysext/core/Tests/Legacy/typo3/contrib/class.removexssTest.php
new file mode 100644 (file)
index 0000000..083dce2
--- /dev/null
@@ -0,0 +1,450 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2009-2011 Steffen Kamper <info@sk-typo3.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(PATH_typo3 . 'contrib/RemoveXSS/RemoveXSS.php');
+
+/**
+ * Testcase for class RemoveXSS
+ *
+ * @author     Steffen Kamper <info@sk-typo3.de>
+ * @package TYPO3
+ * @subpackage contrib
+ * @ see http://ha.ckers.org/xss.html
+ * @ examples from http://ha.ckers.org/xssAttacks.xml
+ */
+class RemoveXSSTest extends tx_phpunit_testcase {
+
+       /**
+        * @test
+        */
+       public function checkAttackScriptAlert() {
+               $testString = "<SCRIPT>alert('XSS')</SCRIPT>";
+               $expectedString = "<sc<x>ript>alert('XSS')</SCRIPT>";
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackScriptSrcJs() {
+               $testString = '<SCRIPT SRC=http://ha.ckers.org/xss.js></SCRIPT>';
+               $expectedString = "<sc<x>ript SRC=http://ha.ckers.org/xss.js></SCRIPT>";
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackScriptAlertFromCharCode() {
+               $testString = '<SCRIPT>alert(String.fromCharCode(88,83,83))</SCRIPT>';
+               $expectedString = '<sc<x>ript>alert(String.fromCharCode(88,83,83))</SCRIPT>';
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackBaseHref() {
+               $testString = "<BASE HREF=\"javascript:alert('XSS');//\">";
+               $expectedString = "<ba<x>se HREF=\"ja<x>vascript:alert('XSS');//\">";
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackBgsound() {
+               $testString = "<BGSOUND SRC=\"javascript:alert('XSS');\">";
+               $expectedString = "<bg<x>sound SRC=\"ja<x>vascript:alert('XSS');\">";
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackBodyBackground() {
+               $testString = "<BODY BACKGROUND=\"javascript:alert('XSS');\">";
+               $expectedString = "<BODY BACKGROUND=\"ja<x>vascript:alert('XSS');\">";
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackBodyOnLoad() {
+               $testString = "<BODY ONLOAD=alert('XSS')>";
+               $expectedString = "<BODY on<x>load=alert('XSS')>";
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackStyleUrl() {
+               $testString = "<DIV STYLE=\"background-image: url(javascript:alert('XSS'))\">";
+               $expectedString = "<DIV st<x>yle=\"background-image: url(ja<x>vascript:alert('XSS'))\">";
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackStyleWidth() {
+               $testString = "<DIV STYLE=\"width: expression(alert('XSS'));\">";
+               $expectedString = "<DIV st<x>yle=\"width: expression(alert('XSS'));\">";
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackFrameset() {
+               $testString = "<FRAMESET><FRAME SRC=\"javascript:alert('XSS');\"></FRAMESET>";
+               $expectedString = "<fr<x>ameset><fr<x>ame SRC=\"ja<x>vascript:alert('XSS');\"></FRAMESET>";
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackIframe() {
+               $testString = "<IFRAME SRC=\"javascript:alert('XSS');\"></IFRAME>";
+               $expectedString = "<if<x>rame SRC=\"ja<x>vascript:alert('XSS');\"></IFRAME>";
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackInputImage() {
+               $testString = "<INPUT TYPE=\"IMAGE\" SRC=\"javascript:alert('XSS');\">";
+               $expectedString = "<INPUT TYPE=\"IMAGE\" SRC=\"ja<x>vascript:alert('XSS');\">";
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackImageSrc() {
+               $testString = "<IMG SRC=\"javascript:alert('XSS');\">";
+               $expectedString = "<IMG SRC=\"ja<x>vascript:alert('XSS');\">";
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackImageSrcNoQuotesNoSemicolon() {
+               $testString = "<IMG SRC=javascript:alert('XSS')>";
+               $expectedString = "<IMG SRC=ja<x>vascript:alert('XSS')>";
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackImageDynsrc() {
+               $testString = "<IMG DYNSRC=\"javascript:alert('XSS');\">";
+               $expectedString = "<IMG DYNSRC=\"ja<x>vascript:alert('XSS');\">";
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackImageLowsrc() {
+               $testString = "<IMG LOWSRC=\"javascript:alert('XSS');\">";
+               $expectedString = "<IMG LOWSRC=\"ja<x>vascript:alert('XSS');\">";
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackStyle() {
+               $testString = "<STYLE>li {list-style-image: url(\"javascript:alert('XSS')\");}</STYLE>";
+               $expectedString = "<st<x>yle>li {list-style-image: url(\"ja<x>vascript:alert('XSS')\");}</STYLE>";
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackImageVbscript() {
+               $testString = "<IMG SRC='vbscript:msgbox(\"XSS\")'>";
+               $expectedString = "<IMG SRC='vb<x>script:msgbox(\"XSS\")'>";
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackLayer() {
+               $testString = "<LAYER SRC=\"http://ha.ckers.org/scriptlet.html\"></LAYER>";
+               $expectedString = "<la<x>yer SRC=\"http://ha.ckers.org/scriptlet.html\"></LAYER>";
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackMeta() {
+               $testString = '<META HTTP-EQUIV="refresh" CONTENT="0;url=javascript:alert(\'XSS\');">';
+               $expectedString = '<me<x>ta HTTP-EQUIV="refresh" CONTENT="0;url=ja<x>vascript:alert(\'XSS\');">';
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackMetaWithUrl() {
+               $testString = '<META HTTP-EQUIV="refresh" CONTENT="0;url=data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K">';
+               $expectedString = '<me<x>ta HTTP-EQUIV="refresh" CONTENT="0;url=data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K">';
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackMetaWithUrlExtended() {
+               $testString = '<META HTTP-EQUIV="refresh" CONTENT="0; URL=http://;URL=javascript:alert(\'XSS\');">';
+               $expectedString = '<me<x>ta HTTP-EQUIV="refresh" CONTENT="0; URL=http://;URL=ja<x>vascript:alert(\'XSS\');">';
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackObject() {
+               $testString = '<OBJECT TYPE="text/x-scriptlet" DATA="http://ha.ckers.org/scriptlet.html"></OBJECT>';
+               $expectedString = '<ob<x>ject TYPE="text/x-scriptlet" DATA="http://ha.ckers.org/scriptlet.html"></OBJECT>';
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackObjectEmbeddedXss() {
+               $testString = '<OBJECT classid=clsid:ae24fdae-03c6-11d1-8b76-0080c744f389><param name=url value=javascript:alert(\'XSS\')></OBJECT>';
+               $expectedString = '<ob<x>ject classid=clsid:ae24fdae-03c6-11d1-8b76-0080c744f389><param name=url value=ja<x>vascript:alert(\'XSS\')></OBJECT>';
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackEmbedFlash() {
+               $testString = '<EMBED SRC="http://ha.ckers.org/xss.swf" AllowScriptAccess="always"></EMBED>';
+               $expectedString = '<em<x>bed SRC="http://ha.ckers.org/xss.swf" AllowScriptAccess="always"></EMBED>';
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackActionScriptEval() {
+               $testString = 'a="get";b="URL("";c="javascript:";d="alert(\'XSS\');")";eval(a+b+c+d);";';
+               $expectedString = 'a="get";b="URL("";c="ja<x>vascript:";d="alert(\'XSS\');")";eval(a+b+c+d);";';
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackImageStyleWithComment() {
+               $testString = '<IMG STYLE="xss:expr/*XSS*/ession(alert(\'XSS\'))">';
+               $expectedString = '<IMG st<x>yle="xss:expr/*XSS*/ession(alert(\'XSS\'))">';
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackStyleInAnonymousHtml() {
+               $testString = '<XSS STYLE="xss:expression(alert(\'XSS\'))">';
+               $expectedString = '<XSS st<x>yle="xss:expression(alert(\'XSS\'))">';
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackStyleWithBackgroundImage() {
+               $testString = '<STYLE>.XSS{background-image:url("javascript:alert(\'XSS\')");}</STYLE><A CLASS=XSS></A>';
+               $expectedString = '<st<x>yle>.XSS{background-image:url("ja<x>vascript:alert(\'XSS\')");}</STYLE><A CLASS=XSS></A>';
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackStyleWithBackground() {
+               $testString = '<STYLE type="text/css">BODY{background:url("javascript:alert(\'XSS\')")}</STYLE>';
+               $expectedString = '<st<x>yle type="text/css">BODY{background:url("ja<x>vascript:alert(\'XSS\')")}</STYLE>';
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackStylesheet() {
+               $testString = '<LINK REL="stylesheet" HREF="javascript:alert(\'XSS\');">';
+               $expectedString = '<li<x>nk REL="stylesheet" HREF="ja<x>vascript:alert(\'XSS\');">';
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackRemoteStylesheet() {
+               $testString = '<LINK REL="stylesheet" HREF="http://ha.ckers.org/xss.css">';
+               $expectedString = '<li<x>nk REL="stylesheet" HREF="http://ha.ckers.org/xss.css">';
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackImportRemoteStylesheet() {
+               $testString = '<STYLE>@import\'http://ha.ckers.org/xss.css\';</STYLE>';
+               $expectedString = '<st<x>yle>@import\'http://ha.ckers.org/xss.css\';</STYLE>';
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+
+       /**
+        * @return array<array> input strings and expected output strings to test
+        *
+        * @see processWithDataProvider
+        */
+       public function processDataProvider() {
+               return array(
+                       'attackWithHexEncodedCharacter' => array(
+                               '<a href="j&#x61;vascript:alert(123);">click</a>',
+                               '<a href="ja<x>vascript:alert(123);">click</a>',
+                       ),
+                       'attackWithNestedHexEncodedCharacter' => array(
+                               '<a href="j&#x6&#x31;;vascript:alert(123);">click</a>',
+                               '<a href="ja<x>vascript:alert(123);">click</a>',
+                       ),
+                       'attackWithUnicodeNumericalEncodedCharacter' => array(
+                               '<a href="j&#x6&#x31;;vascript:alert(123);">click</a>',
+                               '<a href="ja<x>vascript:alert(123);">click</a>',
+                       ),
+                       'attackWithNestedUnicodeNumericalEncodedCharacter' => array(
+                               '<a href="j&#6&#53;;vascript:alert(123);">click</a>',
+                               '<a href="ja<x>vascript:alert(123);">click</a>',
+                       ),
+                       'attack with null character' => array(
+                               '<scr' . chr(0) . 'ipt></script>',
+                               '<sc<x>ript></script>'
+                       ),
+                       'attack with null character in attribute' => array(
+                               '<a href="j' . chr(0) . 'avascript:alert(123);"></a>',
+                               '<a href="ja<x>vascript:alert(123);"></a>'
+                       ),
+               );
+       }
+
+       /**
+        * @test
+        *
+        * @param string $input input value to test
+        * @param string $expected expected output value
+        *
+        * @dataProvider processDataProvider
+        */
+       public function processWithDataProvider($input, $expected) {
+               $this->assertEquals(
+                       $expected,
+                       RemoveXSS::process($input)
+               );
+       }
+
+       /**
+        * Allowed combinations
+        */
+       public function processValidDataProvider() {
+               return array(
+                       'multibyte characters' => array(
+                               '<img®€ÜüÖöÄä></img>',
+                       ),
+                       'tab' => array(
+                               '<im' . chr(9) . 'g></img>',
+                       ),
+                       'line feed' => array(
+                               '<im' . chr(10) . 'g></img>',
+                       ),
+                       'carriage return' => array(
+                               '<im' . chr(13) . 'g></img>',
+                       ),
+               );
+       }
+
+       /**
+        * @test
+        * @param string $input Value to test
+        * @dataProvider processValidDataProvider
+        */
+       public function proccessValidStrings($input) {
+               $this->assertEquals(
+                       $input,
+                       RemoveXSS::process($input)
+               );
+       }
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/core/Tests/Unit/Resource/ResourceStorageTest.php b/typo3/sysext/core/Tests/Unit/Resource/ResourceStorageTest.php
new file mode 100644 (file)
index 0000000..fd46ff7
--- /dev/null
@@ -0,0 +1,614 @@
+<?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 ResourceStorageTest extends \TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCase {
+
+       /**
+        * @var array A backup of registered singleton instances
+        */
+       protected $singletonInstances = array();
+
+       /**
+        * @var \TYPO3\CMS\Core\Resource\ResourceStorage
+        */
+       private $fixture;
+
+       public function setUp() {
+               parent::setUp();
+               $this->singletonInstances = \TYPO3\CMS\Core\Utility\GeneralUtility::getSingletonInstances();
+               \TYPO3\CMS\Core\Utility\GeneralUtility::purgeInstances();
+       }
+
+       public function tearDown() {
+               parent::tearDown();
+               \TYPO3\CMS\Core\Utility\GeneralUtility::resetSingletonInstances($this->singletonInstances);
+       }
+
+       /**
+        * 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
+               /** @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/typo3/sysext/core/Tests/Unit/Resource/StorageTest.php b/typo3/sysext/core/Tests/Unit/Resource/StorageTest.php
deleted file mode 100644 (file)
index 29815ab..0000000
+++ /dev/null
@@ -1,614 +0,0 @@
-<?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 array A backup of registered singleton instances
-        */
-       protected $singletonInstances = array();
-
-       /**
-        * @var \TYPO3\CMS\Core\Resource\ResourceStorage
-        */
-       private $fixture;
-
-       public function setUp() {
-               parent::setUp();
-               $this->singletonInstances = \TYPO3\CMS\Core\Utility\GeneralUtility::getSingletonInstances();
-               \TYPO3\CMS\Core\Utility\GeneralUtility::purgeInstances();
-       }
-
-       public function tearDown() {
-               parent::tearDown();
-               \TYPO3\CMS\Core\Utility\GeneralUtility::resetSingletonInstances($this->singletonInstances);
-       }
-
-       /**
-        * 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
-               /** @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