[TASK] Move unit test to logical places
authorStefano Kowalke <blueduck@gmx.net>
Mon, 18 Apr 2011 13:19:02 +0000 (15:19 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Thu, 12 Apr 2012 17:02:41 +0000 (19:02 +0200)
* System extensions should ship with their tests
* Tests for typo3/ and t3lib/ classes are the only ones kept under our root "tests/".

Change-Id: Ic2c1ee29807c1a87202cd78635d4fbc4bf60848a
Resolves: #25869
Releases: 6.0, 4.7
Reviewed-on: http://review.typo3.org/1648
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
tests/contrib/class.removexssTest.php [deleted file]
tests/typo3/contrib/class.removexssTest.php [new file with mode: 0644]
tests/typo3/sysext/cms/tslib/class.tslib_adminpanelTest.php [deleted file]
tests/typo3/sysext/cms/tslib/class.tslib_contentTest.php [deleted file]
tests/typo3/sysext/cms/tslib/class.tslib_feTest.php [deleted file]
typo3/sysext/cms/tests/tslib/class.tslib_adminpanelTest.php [new file with mode: 0644]
typo3/sysext/cms/tests/tslib/class.tslib_contentTest.php [new file with mode: 0644]
typo3/sysext/cms/tests/tslib/class.tslib_feTest.php [new file with mode: 0644]

diff --git a/tests/contrib/class.removexssTest.php b/tests/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
diff --git a/tests/typo3/contrib/class.removexssTest.php b/tests/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/tests/typo3/sysext/cms/tslib/class.tslib_adminpanelTest.php b/tests/typo3/sysext/cms/tslib/class.tslib_adminpanelTest.php
deleted file mode 100644 (file)
index ad7b88f..0000000
+++ /dev/null
@@ -1,90 +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 the "tslib_AdminPanel" class in the TYPO3 Core.
- *
- * @package TYPO3
- * @subpackage tslib
- * @author Christian Kuhn <lolli@schwarzbu.ch>
- */
-class tslib_AdminPanelTest extends tx_phpunit_testcase {
-
-       /**
-        * Enable backup of global and system variables
-        *
-        * @var boolean
-        */
-       protected $backupGlobals = TRUE;
-
-       /**
-        * Exclude TYPO3_DB from backup/ restore of $GLOBALS
-        * because resource types cannot be handled during serializing
-        *
-        * @var array
-        */
-       protected $backupGlobalsBlacklist = array('TYPO3_DB');
-
-       /////////////////////////////////////////////
-       // Test concerning extendAdminPanel hook
-       /////////////////////////////////////////////
-
-       /**
-        * @test
-        * @expectedException UnexpectedValueException
-        */
-       public function extendAdminPanelHookThrowsExceptionIfHookClassDoesNotImplementInterface() {
-               $hookClass = uniqid('tx_coretest');
-               eval('class ' . $hookClass . ' {}');
-
-               $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_adminpanel.php']['extendAdminPanel'][] = $hookClass;
-
-               $adminPanelMock = $this->getMock('tslib_AdminPanel', array('dummy'), array(), '', FALSE);
-               $adminPanelMock->display();
-       }
-
-       /**
-        * @test
-        */
-       public function extendAdminPanelHookCallsExtendAdminPanelMethodOfHook() {
-               $hookClass = uniqid('tx_coretest');
-               $hookMock = $this->getMock(
-                       'tslib_adminPanelHook',
-                       array(),
-                       array(),
-                       $hookClass
-               );
-               $GLOBALS['T3_VAR']['getUserObj'][$hookClass] = $hookMock;
-               $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_adminpanel.php']['extendAdminPanel'][] = $hookClass;
-
-               $adminPanelMock = $this->getMock('tslib_AdminPanel', array('dummy'), array(), '', FALSE);
-
-               $hookMock->expects($this->once())
-                       ->method('extendAdminPanel')
-                       ->with($this->isType('string'), $this->isInstanceOf('tslib_AdminPanel'));
-
-               $adminPanelMock->display();
-       }
-}
-?>
\ No newline at end of file
diff --git a/tests/typo3/sysext/cms/tslib/class.tslib_contentTest.php b/tests/typo3/sysext/cms/tslib/class.tslib_contentTest.php
deleted file mode 100644 (file)
index 3bdf3e2..0000000
+++ /dev/null
@@ -1,919 +0,0 @@
-<?php
-/***************************************************************
-*  Copyright notice
-*
-*  (c) 2009-2011 Oliver Hader <oliver@typo3.org>
-*  All rights reserved
-*
-*  This script is part of the TYPO3 project. The TYPO3 project is
-*  free software; you can redistribute it and/or modify
-*  it under the terms of the GNU General Public License as published by
-*  the Free Software Foundation; either version 2 of the License, or
-*  (at your option) any later version.
-*
-*  The GNU General Public License can be found at
-*  http://www.gnu.org/copyleft/gpl.html.
-*
-*  This script is distributed in the hope that it will be useful,
-*  but WITHOUT ANY WARRANTY; without even the implied warranty of
-*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-*  GNU General Public License for more details.
-*
-*  This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-
-/**
- * Testcase for the "tslib_cObj" class in the TYPO3 Core.
- *
- * @package TYPO3
- * @subpackage tslib
- *
- * @author Oliver Hader <oliver@typo3.org>
- * @author Oliver Klee <typo3-coding@oliverklee.de>
- */
-class tslib_contentTest extends tx_phpunit_testcase {
-       /**
-        * @var array
-        */
-       private $backupGlobalVariables;
-
-       /**
-        * @var tslib_cObj
-        */
-       private $cObj;
-
-       /**
-        * @var tslib_fe
-        */
-       private $tsfe;
-
-       /**
-        * @var t3lib_TStemplate
-        */
-       private $template;
-
-       /**
-        * @var array
-        */
-       private $typoScriptImage;
-
-       public function setUp() {
-               $this->backupGlobalVariables = array(
-                       '_GET' => $_GET,
-                       '_POST' => $_POST,
-                       '_SERVER' => $_SERVER,
-                       'TYPO3_CONF_VARS' => $GLOBALS['TYPO3_CONF_VARS'],
-               );
-
-               $this->template = $this->getMock(
-                       't3lib_TStemplate', array('getFileName', 'linkData')
-               );
-               $this->tsfe = $this->getMock('tslib_fe', array(), array(), '', FALSE);
-               $this->tsfe->tmpl = $this->template;
-               $this->tsfe->config = array();
-               $GLOBALS['TSFE'] = $this->tsfe;
-               $GLOBALS['TSFE']->csConvObj = new t3lib_cs();
-               $GLOBALS['TSFE']->renderCharset = 'utf-8';
-               $GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_utils'] = 'mbstring';
-
-               $className = 'tslib_cObj_' . uniqid('test');
-               eval('
-                       class ' . $className . ' extends tslib_cObj {
-                               public $stdWrapHookObjects = array();
-                               public $getImgResourceHookObjects;
-                       }
-               ');
-
-               $this->cObj = new $className();
-               $this->cObj->start(array(), 'tt_content');
-
-               $this->typoScriptImage = array(
-                       'file' => 'typo3/clear.gif',
-               );
-       }
-
-       public function tearDown() {
-               foreach ($this->backupGlobalVariables as $key => $data) {
-                       $GLOBALS[$key] = $data;
-               }
-
-               $GLOBALS['TSFE'] = NULL;
-
-               unset($this->cObj, $this->tsfe, $this->template, $this->typoScriptImage);
-       }
-
-
-       ////////////////////////
-       // Utitility functions
-       ////////////////////////
-
-       /**
-        * Converts the subject and the expected result into the target charset.
-        *
-        * @param string $charset the target charset
-        * @param string $subject the subject, will be modified
-        * @param string $expected the expected result, will be modified
-        */
-       protected function handleCharset($charset, &$subject, &$expected) {
-               $GLOBALS['TSFE']->renderCharset = $charset;
-               $subject = $GLOBALS['TSFE']->csConvObj->conv($subject, 'iso-8859-1', $charset);
-               $expected = $GLOBALS['TSFE']->csConvObj->conv($expected, 'iso-8859-1', $charset);
-       }
-
-
-       /////////////////////////////////////////////
-       // Tests concerning the getImgResource hook
-       /////////////////////////////////////////////
-
-       /**
-        * @test
-        */
-       public function getImgResourceHookGetsCalled() {
-               $this->template->expects($this->atLeastOnce())->method('getFileName')
-                       ->with('typo3/clear.gif')->will($this->returnValue('typo3/clear.gif'));
-
-               $className = uniqid('tx_coretest');
-               $getImgResourceHookMock = $this->getMock(
-                       'tslib_cObj_getImgResourceHook',
-                       array('getImgResourcePostProcess'),
-                       array(),
-                       $className
-               );
-
-               $getImgResourceHookMock->expects($this->once())->method('getImgResourcePostProcess')
-                       ->will($this->returnCallback(array($this, 'isGetImgResourceHookCalledCallback')));
-               $this->cObj->getImgResourceHookObjects = array($getImgResourceHookMock);
-
-               $this->cObj->IMAGE($this->typoScriptImage);
-       }
-
-       /**
-        * Handles the arguments that have been sent to the getImgResource hook.
-        *
-        * @return      array
-        *
-        * @see getImgResourceHookGetsCalled
-        */
-       public function isGetImgResourceHookCalledCallback() {
-               list($file, $fileArray, $imageResource, $parent) = func_get_args();
-
-               $this->assertEquals('typo3/clear.gif', $file);
-               $this->assertEquals('typo3/clear.gif', $imageResource['origFile']);
-               $this->assertTrue(is_array($fileArray));
-               $this->assertTrue($parent instanceof tslib_cObj);
-
-               return $imageResource;
-       }
-
-
-       //////////////////////////
-       // Tests concerning FORM
-       //////////////////////////
-
-       /**
-        * @test
-        */
-       public function formWithSecureFormMailEnabledDoesNotContainRecipientField() {
-               $GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail'] = TRUE;
-
-               $this->assertNotContains(
-                       'name="recipient',
-                       $this->cObj->FORM(
-                               array('recipient' => 'foo@bar.com', 'recipient.' => array()),
-                               array()
-                       )
-               );
-       }
-
-       /**
-        * @test
-        */
-       public function formWithSecureFormMailDisabledDoesNotContainRecipientField() {
-               $GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail'] = FALSE;
-
-               $this->assertContains(
-                       'name="recipient',
-                       $this->cObj->FORM(
-                               array('recipient' => 'foo@bar.com', 'recipient.' => array()),
-                               array()
-                       )
-               );
-       }
-
-
-       /////////////////////////////////////////
-       // Tests concerning getQueryArguments()
-       /////////////////////////////////////////
-
-       /**
-        * @test
-        */
-       public function getQueryArgumentsExcludesParameters() {
-               $_SERVER['QUERY_STRING'] =
-                       'key1=value1' .
-                       '&key2=value2' .
-                       '&key3[key31]=value31' .
-                       '&key3[key32][key321]=value321' .
-                       '&key3[key32][key322]=value322';
-
-               $getQueryArgumentsConfiguration = array();
-               $getQueryArgumentsConfiguration['exclude'] = array();
-               $getQueryArgumentsConfiguration['exclude'][] = 'key1';
-               $getQueryArgumentsConfiguration['exclude'][] = 'key3[key31]';
-               $getQueryArgumentsConfiguration['exclude'][] = 'key3[key32][key321]';
-               $getQueryArgumentsConfiguration['exclude'] = implode(',', $getQueryArgumentsConfiguration['exclude']);
-
-               $expectedResult = $this->rawUrlEncodeSquareBracketsInUrl('&key2=value2&key3[key32][key322]=value322');
-               $actualResult = $this->cObj->getQueryArguments($getQueryArgumentsConfiguration);
-               $this->assertEquals($expectedResult, $actualResult);
-       }
-
-       /**
-        * @test
-        */
-       public function getQueryArgumentsExcludesGetParameters() {
-               $_GET = array(
-                       'key1' => 'value1',
-                       'key2' => 'value2',
-                       'key3' => array(
-                               'key31' => 'value31',
-                               'key32' => array(
-                                       'key321' => 'value321',
-                                       'key322' => 'value322',
-                               ),
-                       ),
-               );
-
-               $getQueryArgumentsConfiguration = array();
-               $getQueryArgumentsConfiguration['method'] = 'GET';
-               $getQueryArgumentsConfiguration['exclude'] = array();
-               $getQueryArgumentsConfiguration['exclude'][] = 'key1';
-               $getQueryArgumentsConfiguration['exclude'][] = 'key3[key31]';
-               $getQueryArgumentsConfiguration['exclude'][] = 'key3[key32][key321]';
-               $getQueryArgumentsConfiguration['exclude'] = implode(',', $getQueryArgumentsConfiguration['exclude']);
-
-               $expectedResult = $this->rawUrlEncodeSquareBracketsInUrl('&key2=value2&key3[key32][key322]=value322');
-               $actualResult = $this->cObj->getQueryArguments($getQueryArgumentsConfiguration);
-               $this->assertEquals($expectedResult, $actualResult);
-       }
-
-       /**
-        * @test
-        */
-       public function getQueryArgumentsOverrulesSingleParameter() {
-               $_SERVER['QUERY_STRING'] = 'key1=value1';
-
-               $getQueryArgumentsConfiguration = array();
-
-               $overruleArguments = array(
-                               // Should be overriden
-                       'key1' => 'value1Overruled',
-                               // Shouldn't be set: Parameter doesn't exist in source array and is not forced
-                       'key2' => 'value2Overruled',
-               );
-
-               $expectedResult = '&key1=value1Overruled';
-               $actualResult = $this->cObj->getQueryArguments($getQueryArgumentsConfiguration, $overruleArguments);
-               $this->assertEquals($expectedResult, $actualResult);
-       }
-
-       /**
-        * @test
-        */
-       public function getQueryArgumentsOverrulesMultiDimensionalParameters() {
-               $_POST = array(
-                       'key1' => 'value1',
-                       'key2' => 'value2',
-                       'key3' => array(
-                               'key31' => 'value31',
-                               'key32' => array(
-                                       'key321' => 'value321',
-                                       'key322' => 'value322',
-                               ),
-                       ),
-               );
-
-               $getQueryArgumentsConfiguration = array();
-               $getQueryArgumentsConfiguration['method'] = 'POST';
-               $getQueryArgumentsConfiguration['exclude'] = array();
-               $getQueryArgumentsConfiguration['exclude'][] = 'key1';
-               $getQueryArgumentsConfiguration['exclude'][] = 'key3[key31]';
-               $getQueryArgumentsConfiguration['exclude'][] = 'key3[key32][key321]';
-               $getQueryArgumentsConfiguration['exclude'] = implode(',', $getQueryArgumentsConfiguration['exclude']);
-
-               $overruleArguments = array(
-                               // Should be overriden
-                       'key2' => 'value2Overruled',
-                       'key3' => array(
-                               'key32' => array(
-                                               // Shouldn't be set: Parameter is excluded and not forced
-                                       'key321' => 'value321Overruled',
-                                               // Should be overriden: Parameter is not excluded
-                                       'key322' => 'value322Overruled',
-                                               // Shouldn't be set: Parameter doesn't exist in source array and is not forced
-                                       'key323' => 'value323Overruled',
-                               ),
-                       ),
-               );
-
-               $expectedResult = $this->rawUrlEncodeSquareBracketsInUrl('&key2=value2Overruled&key3[key32][key322]=value322Overruled');
-               $actualResult = $this->cObj->getQueryArguments($getQueryArgumentsConfiguration, $overruleArguments);
-               $this->assertEquals($expectedResult, $actualResult);
-       }
-
-       /**
-        * @test
-        */
-       public function getQueryArgumentsOverrulesMultiDimensionalForcedParameters() {
-               $_SERVER['QUERY_STRING'] =
-                       'key1=value1' .
-                       '&key2=value2' .
-                       '&key3[key31]=value31' .
-                       '&key3[key32][key321]=value321' .
-                       '&key3[key32][key322]=value322';
-
-               $_POST = array(
-                       'key1' => 'value1',
-                       'key2' => 'value2',
-                       'key3' => array(
-                               'key31' => 'value31',
-                               'key32' => array(
-                                       'key321' => 'value321',
-                                       'key322' => 'value322',
-                               ),
-                       ),
-               );
-
-               $getQueryArgumentsConfiguration = array();
-               $getQueryArgumentsConfiguration['exclude'] = array();
-               $getQueryArgumentsConfiguration['exclude'][] = 'key1';
-               $getQueryArgumentsConfiguration['exclude'][] = 'key3[key31]';
-               $getQueryArgumentsConfiguration['exclude'][] = 'key3[key32][key321]';
-               $getQueryArgumentsConfiguration['exclude'][] = 'key3[key32][key322]';
-               $getQueryArgumentsConfiguration['exclude'] = implode(',', $getQueryArgumentsConfiguration['exclude']);
-
-               $overruleArguments = array(
-                               // Should be overriden
-                       'key2' => 'value2Overruled',
-                       'key3' => array(
-                               'key32' => array(
-                                               // Should be set: Parameter is excluded but forced
-                                       'key321' => 'value321Overruled',
-                                               // Should be set: Parameter doesn't exist in source array but is forced
-                                       'key323' => 'value323Overruled',
-                               ),
-                       ),
-               );
-
-               $expectedResult = $this->rawUrlEncodeSquareBracketsInUrl('&key2=value2Overruled&key3[key32][key321]=value321Overruled&key3[key32][key323]=value323Overruled');
-               $actualResult = $this->cObj->getQueryArguments($getQueryArgumentsConfiguration, $overruleArguments, TRUE);
-               $this->assertEquals($expectedResult, $actualResult);
-
-               $getQueryArgumentsConfiguration['method'] = 'POST';
-               $actualResult = $this->cObj->getQueryArguments($getQueryArgumentsConfiguration, $overruleArguments, TRUE);
-               $this->assertEquals($expectedResult, $actualResult);
-       }
-
-       /**
-        * Encodes square brackets in URL.
-        *
-        * @param string $string
-        * @return string
-        */
-       private function rawUrlEncodeSquareBracketsInUrl($string) {
-               return str_replace(
-                       array('[', ']'),
-                       array('%5B', '%5D'),
-                       $string
-               );
-       }
-
-
-       //////////////////////////////
-       // Tests concerning crop
-       //////////////////////////////
-
-       /**
-        * @test
-        */
-       public function cropIsMultibyteSafe() {
-               $this->assertEquals('бла', $this->cObj->crop('бла', '3|...'));
-       }
-
-       //////////////////////////////
-       // Tests concerning cropHTML
-       //////////////////////////////
-
-       /**
-        * This is the data provider for the tests of crop and cropHTML below. It provides all combinations
-        * of charset, text type, and configuration options to be tested.
-        *
-        * @return array two-dimensional array with the second level like this:
-        *               0 => the settings for the crop function, for example "-58|..."
-        *               1 => the string to crop
-        *               2 => the expected cropped result
-        *               3 => the charset that will be set as renderCharset
-        *
-        * @see cropHtmlWithDataProvider
-        */
-       public function cropHtmlDataProvider() {
-               $plainText = 'Kasper Sk' . chr(229) . 'rh' . chr(248) .
-                       'j implemented the original version of the crop function.';
-               $textWithMarkup = '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' .
-                       chr(229) . 'rh' . chr(248) . 'j</a>' .
-                       ' implemented</strong> the original version of the crop function.';
-               $textWithEntities = 'Kasper Sk&aring;rh&oslash;j implemented the; original ' .
-                       'version of the crop function.';
-
-               $charsets = array('iso-8859-1', 'utf-8', 'ascii', 'big5');
-
-               $data = array();
-               foreach ($charsets as $charset) {
-                       $data = array_merge($data, array(
-                               $charset . ' plain text; 11|...' => array(
-                                       '11|...', $plainText, 'Kasper Sk' . chr(229) . 'r...', $charset
-                               ),
-                               $charset . ' plain text; -58|...' => array(
-                                       '-58|...', $plainText, '...h' . chr(248) . 'j implemented the original version of the crop function.', $charset
-                               ),
-                               $charset . ' plain text; 4|...|1' => array(
-                                       '4|...|1', $plainText, 'Kasp...', $charset
-                               ),
-                               $charset . ' plain text; 20|...|1' => array(
-                                       '20|...|1', $plainText, 'Kasper Sk' . chr(229) . 'rh' . chr(248) . 'j...', $charset
-                               ),
-                               $charset . ' plain text; -5|...|1' => array(
-                                       '-5|...|1', $plainText, '...tion.', $charset
-                               ),
-                               $charset . ' plain text; -49|...|1' => array(
-                                       '-49|...|1', $plainText, '...the original version of the crop function.', $charset
-                               ),
-                               $charset . ' text with markup; 11|...' => array(
-                                       '11|...', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) . 'r...</a></strong>', $charset
-                               ),
-                               $charset . ' text with markup; 13|...' => array(
-                                       '13|...', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) . 'rh' . chr(248) . '...</a></strong>', $charset
-                               ),
-                               $charset . ' text with markup; 14|...' => array(
-                                       '14|...', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) . 'rh' . chr(248) . 'j</a>...</strong>', $charset
-                               ),
-                               $charset . ' text with markup; 15|...' => array(
-                                       '15|...', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) . 'rh' . chr(248) . 'j</a> ...</strong>', $charset
-                               ),
-                               $charset . ' text with markup; 29|...' => array(
-                                       '29|...', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) . 'rh' . chr(248) . 'j</a> implemented</strong> th...', $charset
-                               ),
-                               $charset . ' text with markup; -58|...' => array(
-                                       '-58|...', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">...h' . chr(248) . 'j</a> implemented</strong> the original version of the crop function.', $charset
-                               ),
-                               $charset . ' text with markup 4|...|1' => array(
-                                       '4|...|1', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasp...</a></strong>', $charset
-                               ),
-                               $charset . ' text with markup; 11|...|1' => array(
-                                       '11|...|1', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper...</a></strong>', $charset
-                               ),
-                               $charset . ' text with markup; 13|...|1' => array(
-                                       '13|...|1', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper...</a></strong>', $charset
-                               ),
-                               $charset . ' text with markup; 14|...|1' => array(
-                                       '14|...|1', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) . 'rh' . chr(248) . 'j</a>...</strong>', $charset
-                               ),
-                               $charset . ' text with markup; 15|...|1' => array(
-                                       '15|...|1', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) . 'rh' . chr(248) . 'j</a>...</strong>', $charset
-                               ),
-                               $charset . ' text with markup; 29|...|1' => array(
-                                       '29|...|1', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) . 'rh' . chr(248) . 'j</a> implemented</strong>...', $charset
-                               ),
-                               $charset . ' text with markup; -66|...|1' => array(
-                                       '-66|...|1', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">...Sk' . chr(229) . 'rh' . chr(248) . 'j</a> implemented</strong> the original version of the crop function.', $charset
-                               ),
-                               $charset . ' text with entities 9|...' => array(
-                                       '9|...', $textWithEntities, 'Kasper Sk...', $charset
-                               ),
-                               $charset . ' text with entities 10|...' => array(
-                                       '10|...', $textWithEntities, 'Kasper Sk&aring;...', $charset
-                               ),
-                               $charset . ' text with entities 11|...' => array(
-                                       '11|...', $textWithEntities, 'Kasper Sk&aring;r...', $charset
-                               ),
-                               $charset . ' text with entities 13|...' => array(
-                                       '13|...', $textWithEntities, 'Kasper Sk&aring;rh&oslash;...', $charset
-                               ),
-                               $charset . ' text with entities 14|...' => array(
-                                       '14|...', $textWithEntities, 'Kasper Sk&aring;rh&oslash;j...', $charset
-                               ),
-                               $charset . ' text with entities 15|...' => array(
-                                       '15|...', $textWithEntities, 'Kasper Sk&aring;rh&oslash;j ...', $charset
-                               ),
-                               $charset . ' text with entities 16|...' => array(
-                                       '16|...', $textWithEntities, 'Kasper Sk&aring;rh&oslash;j i...', $charset
-                               ),
-                               $charset . ' text with entities -57|...' => array(
-                                       '-57|...', $textWithEntities, '...j implemented the; original version of the crop function.', $charset
-                               ),
-                               $charset . ' text with entities -58|...' => array(
-                                       '-58|...', $textWithEntities, '...&oslash;j implemented the; original version of the crop function.', $charset
-                               ),
-                               $charset . ' text with entities -59|...' => array(
-                                       '-59|...', $textWithEntities, '...h&oslash;j implemented the; original version of the crop function.', $charset
-                               ),
-                               $charset . ' text with entities 4|...|1' => array(
-                                       '4|...|1', $textWithEntities, 'Kasp...', $charset
-                               ),
-                               $charset . ' text with entities 9|...|1' => array(
-                                       '9|...|1', $textWithEntities, 'Kasper...', $charset
-                               ),
-                               $charset . ' text with entities 10|...|1' => array(
-                                       '10|...|1', $textWithEntities, 'Kasper...', $charset
-                               ),
-                               $charset . ' text with entities 11|...|1' => array(
-                                       '11|...|1', $textWithEntities, 'Kasper...', $charset
-                               ),
-                               $charset . ' text with entities 13|...|1' => array(
-                                       '13|...|1', $textWithEntities, 'Kasper...', $charset
-                               ),
-                               $charset . ' text with entities 14|...|1' => array(
-                                       '14|...|1', $textWithEntities, 'Kasper Sk&aring;rh&oslash;j...', $charset
-                               ),
-                               $charset . ' text with entities 15|...|1' => array(
-                                       '15|...|1', $textWithEntities, 'Kasper Sk&aring;rh&oslash;j...', $charset
-                               ),
-                               $charset . ' text with entities 16|...|1' => array(
-                                       '16|...|1', $textWithEntities, 'Kasper Sk&aring;rh&oslash;j...', $charset
-                               ),
-                               $charset . ' text with entities -57|...|1' => array(
-                                       '-57|...|1', $textWithEntities, '...implemented the; original version of the crop function.', $charset
-                               ),
-                               $charset . ' text with entities -58|...|1' => array(
-                                       '-58|...|1', $textWithEntities, '...implemented the; original version of the crop function.', $charset
-                               ),
-                               $charset . ' text with entities -59|...|1' => array(
-                                       '-59|...|1', $textWithEntities, '...implemented the; original version of the crop function.', $charset
-                               ),
-                       ));
-               }
-               return $data;
-       }
-
-       /**
-        * Checks if stdWrap.cropHTML works with plain text cropping from left
-        *
-        * @test
-        *
-        * @dataProvider cropHtmlDataProvider
-        *
-        * @param string $settings
-        *        the settings for the crop function, for example "-58|..."
-        * @param string $subject the string to crop
-        * @param string $expected the expected cropped result
-        * @param string $charset the charset that will be set as renderCharset
-        */
-       public function cropHtmlWithDataProvider($settings, $subject, $expected, $charset) {
-               $this->handleCharset($charset, $subject, $expected);
-
-               $this->assertEquals(
-                       $expected,
-                       $this->cObj->cropHTML($subject, $settings),
-                       'cropHTML failed with settings: "' . $settings . '" and charset "' . $charset . '"'
-               );
-       }
-
-       /**
-        * Checks if stdWrap.cropHTML works with a complex content with many tags. Currently cropHTML
-        * counts multiple invisible characters not as one (as the browser will output the content).
-        *
-        * @test
-        */
-       public function cropHtmlWorksWithComplexContent() {
-               $GLOBALS['TSFE']->renderCharset = 'iso-8859-1';
-               $subject = '
-<h1>Blog Example</h1>
-<hr>
-<div class="csc-header csc-header-n1">
-       <h2 class="csc-firstHeader">Welcome to Blog #1</h2>
-</div>
-<p class="bodytext">
-       A blog about TYPO3 extension development. In order to start blogging, read the <a href="#">Help section</a>. If you have any further questions, feel free to contact the administrator John Doe (<a href="mailto:john.doe@example.com">john.doe@example.com)</a>.
-</p>
-<div class="tx-blogexample-list-container">
-       <p class="bodytext">
-               Below are the most recent posts:
-       </p>
-       <ul>
-               <li>
-                       <h3>
-                               <a href="index.php?id=99&amp;tx_blogexample_pi1[post][uid]=211&amp;tx_blogexample_pi1[blog]=&amp;tx_blogexample_pi1[action]=show&amp;tx_blogexample_pi1[controller]=Post&amp;cHash=003b0131ed">The Post #1</a>
-                       </h3>
-                       <p class="bodytext">
-                               Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut...
-                       </p>
-                       <p class="metadata">
-                               Published on 26.08.2009 by Jochen Rau
-                       </p>
-                       <p>
-                               Tags: [MVC]&nbsp;[Domain Driven Design]&nbsp;<br>
-                               <a href="index.php?id=99&amp;tx_blogexample_pi1[post][uid]=211&amp;tx_blogexample_pi1[action]=show&amp;tx_blogexample_pi1[controller]=Post&amp;cHash=f982643bc3">read more &gt;&gt;</a><br>
-                               <a href="index.php?id=99&amp;tx_blogexample_pi1[post][uid]=211&amp;tx_blogexample_pi1[blog][uid]=70&amp;tx_blogexample_pi1[action]=edit&amp;tx_blogexample_pi1[controller]=Post&amp;cHash=5b481bc8f0">Edit</a>&nbsp;<a href="index.php?id=99&amp;tx_blogexample_pi1[post][uid]=211&amp;tx_blogexample_pi1[blog][uid]=70&amp;tx_blogexample_pi1[action]=delete&amp;tx_blogexample_pi1[controller]=Post&amp;cHash=4e52879656">Delete</a>
-                       </p>
-               </li>
-       </ul>
-       <p>
-               <a href="index.php?id=99&amp;tx_blogexample_pi1[blog][uid]=70&amp;tx_blogexample_pi1[action]=new&amp;tx_blogexample_pi1[controller]=Post&amp;cHash=2718a4b1a0">Create a new Post</a>
-       </p>
-</div>
-<hr>
-<p>
-       ? TYPO3 Association
-</p>
-';
-
-               $result = $this->cObj->cropHTML($subject, '300');
-               $expected = '
-<h1>Blog Example</h1>
-<hr>
-<div class="csc-header csc-header-n1">
-       <h2 class="csc-firstHeader">Welcome to Blog #1</h2>
-</div>
-<p class="bodytext">
-       A blog about TYPO3 extension development. In order to start blogging, read the <a href="#">Help section</a>. If you have any further questions, feel free to contact the administrator John Doe (<a href="mailto:john.doe@example.com">john.doe@example.com)</a>.
-</p>
-<div class="tx-blogexample-list-container">
-       <p class="bodytext">
-               Below are the most recent posts:
-       </p>
-       <ul>
-               <li>
-                       <h3>
-                               <a href="index.php?id=99&amp;tx_blogexample_pi1[post][uid]=211&amp;tx_blogexample_pi1[blog]=&amp;tx_blogexample_pi1[action]=show&amp;tx_blogexample_pi1[controller]=Post&amp;cHash=003b0131ed">The Pos</a></h3></li></ul></div>';
-               $this->assertEquals($expected, $result);
-
-               $result = $this->cObj->cropHTML($subject, '-100');
-               $expected = '<div class="tx-blogexample-list-container"><ul><li><p>Design]&nbsp;<br>
-                               <a href="index.php?id=99&amp;tx_blogexample_pi1[post][uid]=211&amp;tx_blogexample_pi1[action]=show&amp;tx_blogexample_pi1[controller]=Post&amp;cHash=f982643bc3">read more &gt;&gt;</a><br>
-                               <a href="index.php?id=99&amp;tx_blogexample_pi1[post][uid]=211&amp;tx_blogexample_pi1[blog][uid]=70&amp;tx_blogexample_pi1[action]=edit&amp;tx_blogexample_pi1[controller]=Post&amp;cHash=5b481bc8f0">Edit</a>&nbsp;<a href="index.php?id=99&amp;tx_blogexample_pi1[post][uid]=211&amp;tx_blogexample_pi1[blog][uid]=70&amp;tx_blogexample_pi1[action]=delete&amp;tx_blogexample_pi1[controller]=Post&amp;cHash=4e52879656">Delete</a>
-                       </p>
-               </li>
-       </ul>
-       <p>
-               <a href="index.php?id=99&amp;tx_blogexample_pi1[blog][uid]=70&amp;tx_blogexample_pi1[action]=new&amp;tx_blogexample_pi1[controller]=Post&amp;cHash=2718a4b1a0">Create a new Post</a>
-       </p>
-</div>
-<hr>
-<p>
-       ? TYPO3 Association
-</p>
-';
-               $this->assertEquals(
-                       $expected,
-                       $result
-               );
-       }
-
-       /**
-        * @return array
-        */
-       public function stdWrap_roundDataProvider() {
-               return array(
-                       'rounding off without any configuration' => array(
-                               1.123456789,
-                               array(
-                               ),
-                               1
-                       ),
-                       'rounding up without any configuration' => array(
-                               1.523456789,
-                               array(
-                               ),
-                               2
-                       ),
-                       'regular rounding (off) to two decimals' => array(
-                               0.123456789,
-                               array(
-                                       'decimals' => 2
-                               ),
-                               0.12
-                       ),
-                       'regular rounding (up) to two decimals' => array(
-                               0.1256789,
-                               array(
-                                       'decimals' => 2
-                               ),
-                               0.13
-                       ),
-                       'rounding up to integer with type ceil' => array(
-                               0.123456789,
-                               array(
-                                       'roundType' => 'ceil'
-                               ),
-                               1
-                       ),
-                       'rounding down to integer with type floor' => array(
-                               2.3481,
-                               array(
-                                       'roundType' => 'floor'
-                               ),
-                               2
-                       )
-               );
-       }
-
-       /**
-        * Test for the stdWrap function "round"
-        *
-        * @param float $float
-        * @param array $conf
-        * @param float $expected
-        * @return void
-        *
-        * @dataProvider stdWrap_roundDataProvider
-        * @test
-        */
-       public function stdWrap_round($float, $conf, $expected) {
-               $conf = array(
-                       'round.' => $conf
-               );
-               $result = $this->cObj->stdWrap_round($float, $conf);
-               $this->assertEquals($expected, $result);
-       }
-
-       /**
-        * Data provider for the hash test
-        *
-        * @return array multi-dimensional array with the second level like this:
-        *               0 => the plain text
-        *               1 => the conf array for the hash stdWrap function
-        *               2 => the expected result
-        *
-        * @see hash
-        */
-       public function hashDataProvider() {
-               $data = array(
-                       'testing md5' => array(
-                               'joh316',
-                               array(
-                                       'hash' => 'md5'
-                               ),
-                               'bacb98acf97e0b6112b1d1b650b84971'
-                       ),
-                       'testing sha1' => array(
-                               'joh316',
-                               array(
-                                       'hash' => 'sha1'
-                               ),
-                               '063b3d108bed9f88fa618c6046de0dccadcf3158'
-                       ),
-                       'testing non-existing hashing algorithm' => array(
-                               'joh316',
-                               array(
-                                       'hash' => 'non-existing'
-                               ),
-                               ''
-                       ),
-                       'testing stdWrap capability' => array(
-                               'joh316',
-                               array(
-                                       'hash.' => array(
-                                               'cObject' => 'TEXT',
-                                               'cObject.' => array(
-                                                       'value' => 'md5'
-                                               )
-                                       )
-                               ),
-                               'bacb98acf97e0b6112b1d1b650b84971'
-                       )
-               );
-               return $data;
-       }
-
-       /**
-        * Test for the stdWrap function "hash"
-        *
-        * @param string $text
-        * @param array $conf
-        * @param string $expected
-        * @return void
-        *
-        * @dataProvider hashDataProvider
-        * @test
-        */
-       public function stdWrap_hash($text, array $conf, $expected) {
-               $result = $this->cObj->stdWrap_hash($text, $conf);
-               $this->assertEquals($expected, $result);
-       }
-
-       /**
-        * Data provider for the numberFormat test
-        *
-        * @return array multi-dimensional array with the second level like this:
-        *               0 => the input float number
-        *               1 => the conf array for the numberFormat stdWrap function
-        *               2 => the expected result
-        *
-        * @see numberFormat
-        */
-       public function numberFormatDataProvider() {
-               $data = array(
-                       'testing decimals' => array(
-                               0.8,
-                               array(
-                                       'decimals' => 2
-                               ),
-                               '0.80'
-                       ),
-                       'testing dec_point' => array(
-                               0.8,
-                               array(
-                                       'decimals' => 1,
-                                       'dec_point' => ','
-                               ),
-                               '0,8'
-                       ),
-                       'testing thousands_sep' => array(
-                               999.99,
-                               array(
-                                       'decimals' => 0,
-                                       'thousands_sep.' => array(
-                                               'char' => 46
-                                       )
-                               ),
-                               '1.000'
-                       ),
-                       'testing mixture' => array(
-                               1281731.45,
-                               array(
-                                       'decimals' => 1,
-                                       'dec_point.' => array(
-                                               'char' => 44
-                                       ),
-                                       'thousands_sep.' => array(
-                                               'char' => 46
-                                       )
-                               ),
-                               '1.281.731,5'
-                       )
-               );
-               return $data;
-       }
-
-       /**
-        * Check if stdWrap.numberFormat and all of its properties work properly
-        *
-        * @dataProvider numberFormatDataProvider
-        *
-        * @test
-        */
-       public function numberFormat($float, $formatConf, $expected) {
-               $result = $this->cObj->numberFormat($float, $formatConf);
-               $this->assertEquals($expected, $result);
-       }
-
-       /**
-        * Data provider for the replacement test
-        *
-        * @return array multi-dimensional array with the second level like this:
-        *               0 => the input text
-        *               1 => the conf array for the replacement stdWrap function
-        *               2 => the expected result
-        *
-        * @see replacement
-        */
-       public function replacementDataProvider() {
-               $data = array(
-                       'multiple replacements, including regex' => array(
-                               'There_is_a_cat,_a_dog_and_a_tiger_in_da_hood!_Yeah!',
-                               array('replacement.' =>
-                                       array(
-                                               '120.' => array(
-                                                       'search' => 'in da hood',
-                                                       'replace' => 'around the block',
-                                               ),
-                                               '20.' => array(
-                                                       'search' => '_',
-                                                       'replace.' => array('char' => '32'),
-                                               ),
-                                               '130.' => array(
-                                                       'search' => '#a (Cat|Dog|Tiger)#i',
-                                                       'replace' => 'an animal',
-                                                       'useRegExp' => '1',
-                                               ),
-                                       ),
-                               ),
-                               'There is an animal, an animal and an animal around the block! Yeah!'
-                       ),
-               );
-               return $data;
-       }
-
-       /**
-        * Check if stdWrap.replacement and all of its properties work properly
-        *
-        * @dataProvider replacementDataProvider
-        *
-        * @test
-        */
-       public function replacement($input, $conf, $expected) {
-               $result = $this->cObj->stdWrap_replacement($input, $conf);
-               $this->assertEquals($expected, $result);
-       }
-}
-?>
\ No newline at end of file
diff --git a/tests/typo3/sysext/cms/tslib/class.tslib_feTest.php b/tests/typo3/sysext/cms/tslib/class.tslib_feTest.php
deleted file mode 100644 (file)
index 8281851..0000000
+++ /dev/null
@@ -1,239 +0,0 @@
-<?php
-/***************************************************************
-* Copyright notice
-*
-* (c) 2009-2011 Oliver Klee (typo3-coding@oliverklee.de)
-* All rights reserved
-*
-* This script is part of the TYPO3 project. The TYPO3 project is
-* free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* The GNU General Public License can be found at
-* http://www.gnu.org/copyleft/gpl.html.
-*
-* This script is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-* GNU General Public License for more details.
-*
-* This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-
-/**
- * Testcase for the "tslib_fe" class in the TYPO3 Core.
- *
- * @package TYPO3
- * @subpackage tslib
- *
- * @author Oliver Klee <typo3-coding@oliverklee.de>
- */
-class tslib_feTest extends tx_phpunit_testcase {
-       /**
-        * @var tslib_fe
-        */
-       private $fixture;
-
-       public function setUp() {
-                       // This creates an instance of the class without calling the
-                       // original constructor.
-               $className = uniqid('tslib_fe');
-               eval(
-                       'class ' . $className . ' extends tslib_fe {' .
-                       'public function ' . $className . '() {}' .
-
-                       'public function roundTripCryptString($string) {' .
-                       'return parent::roundTripCryptString($string);' .
-                       '}' .
-
-                       'public function stripIPv4($strIP) {' .
-                       'return parent::stripIPv4($strIP);' .
-                       '}' .
-
-                       'public function stripIPv6($strIP) {' .
-                       'return parent::stripIPv6($strIP);' .
-                       '}' .
-
-                       '}'
-               );
-
-               $this->fixture = new $className();
-               $this->fixture->TYPO3_CONF_VARS = $GLOBALS['TYPO3_CONF_VARS'];
-               $this->fixture->TYPO3_CONF_VARS['SYS']['encryptionKey']
-                       = '170928423746123078941623042360abceb12341234231';
-       }
-
-       public function tearDown() {
-               unset($this->fixture);
-       }
-
-
-       ////////////////////////////////
-       // Tests concerning codeString
-       ////////////////////////////////
-
-       /**
-        * @test
-        */
-       public function codeStringForNonEmptyStringReturns10CharacterHashAndCodedString() {
-               $this->assertRegExp(
-                       '/^[0-9a-f]{10}:[a-zA-Z0-9+=\/]+$/',
-                       $this->fixture->codeString('Hello world!')
-               );
-       }
-
-       /**
-        * @test
-        */
-       public function decodingCodedStringReturnsOriginalString() {
-               $clearText = 'Hello world!';
-
-               $this->assertEquals(
-                       $clearText,
-                       $this->fixture->codeString(
-                               $this->fixture->codeString($clearText), TRUE
-                       )
-               );
-       }
-
-
-       //////////////////////
-       // Tests concerning sL
-       //////////////////////
-
-       /**
-        * @test
-        */
-       public function localizationReturnsUnchangedStringIfNotLocallangLabel() {
-               $string = uniqid();
-               $this->assertEquals($string, $this->fixture->sL($string));
-       }
-
-
-       //////////////////////////////////////////
-       // Tests concerning roundTripCryptString
-       //////////////////////////////////////////
-
-       /**
-        * @test
-        */
-       public function roundTripCryptStringCreatesStringWithSameLengthAsInputString() {
-               $clearText = 'Hello world!';
-
-               $this->assertEquals(
-                       strlen($clearText),
-                       strlen($this->fixture->roundTripCryptString($clearText))
-               );
-       }
-
-       /**
-        * @test
-        */
-       public function roundTripCryptStringCreatesResultDifferentFromInputString() {
-               $clearText = 'Hello world!';
-
-               $this->assertNotEquals(
-                       $clearText,
-                       $this->fixture->roundTripCryptString($clearText)
-               );
-       }
-
-       /**
-        * @test
-        */
-       public function roundTripCryptStringAppliedTwoTimesReturnsOriginalString() {
-               $clearText = 'Hello world!';
-
-               $this->assertEquals(
-                       $clearText,
-                       $this->fixture->roundTripCryptString(
-                               $this->fixture->roundTripCryptString($clearText)
-                       )
-               );
-       }
-
-       //////////////////////////////////////
-       // Tests concerning stat-anonymization
-       //////////////////////////////////////
-
-       /**
-        * Data provider for stripIPv6Correct
-        *
-        * @return array Data sets
-        */
-       public static function stripIPv4DataProviderCorrect() {
-               return array(
-                       'empty address, prefix-length 24' => array('0.0.0.0', '24', '0.0.0.0'),
-                       'normal address 1, prefix-length 1' => array('1.2.3.4', '1', '0.0.0.0'),
-                       'normal address 2, prefix-length 24' => array('192.168.5.79', '24', '192.168.5.0'),
-                       'normal address 2, prefix-length 30' => array('192.168.5.79', '30', '192.168.5.76'),
-                               // test for no anonymization; full prefix-length
-                       'normal address 2, prefix-length 32' => array('192.168.5.79', '32', '192.168.5.79'),
-                               // test for full anonymization; full prefix-length
-                       'normal address 2, prefix-length 0' => array('192.168.5.79', '0', '0.0.0.0'),
-               );
-       }
-
-       /**
-        * @test
-        * @dataProvider stripIPv4DataProviderCorrect
-        */
-       public function stripIPv4Correct($address, $prefixLength, $anonymized) {
-               $oldConfig = $this->fixture->config;
-
-               $this->fixture->config = array('config' =>
-                       array('stat_IP_anonymize' => '1',
-                               'stat_IP_anonymize_mask_ipv4' => $prefixLength
-                       )
-               );
-
-               $this->assertEquals(
-                       $this->fixture->stripIPv4($address),
-                       $anonymized
-               );
-               $this->fixture->config = $oldConfig;
-       }
-
-       /**
-        * Data provider for stripIPv6Correct
-        *
-        * @return array Data sets
-        */
-       public static function stripIPv6DataProviderCorrect() {
-               return array(
-                       'empty address, prefix-length 96' => array('::', '96', '::'),
-                       'normal address 1, prefix-length 1' => array('1:2:3::4', '1', '::'),
-                       'normal address 2, prefix-length 4' => array('ffff::9876', '4', 'f000::'),
-                       'normal address 2, prefix-length 1' => array('ffff::9876', '1', '8000::'),
-                       'normal address 3, prefix-length 96' => array('abc:def::9876', '96', 'abc:def::'),
-                       'normal address 3, prefix-length 120' => array('abc:def::9876', '120', 'abc:def::9800'),
-                               // test for no anonymization; full prefix-length
-                       'normal address 3, prefix-length 128' => array('abc:def::9876', '128', 'abc:def::9876'),
-                               // test for full anonymization
-                       'normal address 3, prefix-length 0' => array('abc:def::9876', '0', '::'),
-               );
-       }
-
-       /**
-        * @test
-        * @dataProvider stripIPv6DataProviderCorrect
-        */
-       public function stripIPv6Correct($address, $prefixLength, $anonymized) {
-               $oldConfig = $this->fixture->config;
-
-               $this->fixture->config = array('config' =>
-                       array('stat_IP_anonymize' => '1',
-                               'stat_IP_anonymize_mask_ipv6' => $prefixLength
-                       )
-               );
-
-               $this->assertEquals(
-                       $this->fixture->stripIPv6($address),
-                       $anonymized
-               );
-               $this->fixture->config = $oldConfig;
-       }
-}
-?>
\ No newline at end of file
diff --git a/typo3/sysext/cms/tests/tslib/class.tslib_adminpanelTest.php b/typo3/sysext/cms/tests/tslib/class.tslib_adminpanelTest.php
new file mode 100644 (file)
index 0000000..ad7b88f
--- /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 the "tslib_AdminPanel" class in the TYPO3 Core.
+ *
+ * @package TYPO3
+ * @subpackage tslib
+ * @author Christian Kuhn <lolli@schwarzbu.ch>
+ */
+class tslib_AdminPanelTest extends tx_phpunit_testcase {
+
+       /**
+        * Enable backup of global and system variables
+        *
+        * @var boolean
+        */
+       protected $backupGlobals = TRUE;
+
+       /**
+        * Exclude TYPO3_DB from backup/ restore of $GLOBALS
+        * because resource types cannot be handled during serializing
+        *
+        * @var array
+        */
+       protected $backupGlobalsBlacklist = array('TYPO3_DB');
+
+       /////////////////////////////////////////////
+       // Test concerning extendAdminPanel hook
+       /////////////////////////////////////////////
+
+       /**
+        * @test
+        * @expectedException UnexpectedValueException
+        */
+       public function extendAdminPanelHookThrowsExceptionIfHookClassDoesNotImplementInterface() {
+               $hookClass = uniqid('tx_coretest');
+               eval('class ' . $hookClass . ' {}');
+
+               $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_adminpanel.php']['extendAdminPanel'][] = $hookClass;
+
+               $adminPanelMock = $this->getMock('tslib_AdminPanel', array('dummy'), array(), '', FALSE);
+               $adminPanelMock->display();
+       }
+
+       /**
+        * @test
+        */
+       public function extendAdminPanelHookCallsExtendAdminPanelMethodOfHook() {
+               $hookClass = uniqid('tx_coretest');
+               $hookMock = $this->getMock(
+                       'tslib_adminPanelHook',
+                       array(),
+                       array(),
+                       $hookClass
+               );
+               $GLOBALS['T3_VAR']['getUserObj'][$hookClass] = $hookMock;
+               $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_adminpanel.php']['extendAdminPanel'][] = $hookClass;
+
+               $adminPanelMock = $this->getMock('tslib_AdminPanel', array('dummy'), array(), '', FALSE);
+
+               $hookMock->expects($this->once())
+                       ->method('extendAdminPanel')
+                       ->with($this->isType('string'), $this->isInstanceOf('tslib_AdminPanel'));
+
+               $adminPanelMock->display();
+       }
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/cms/tests/tslib/class.tslib_contentTest.php b/typo3/sysext/cms/tests/tslib/class.tslib_contentTest.php
new file mode 100644 (file)
index 0000000..3bdf3e2
--- /dev/null
@@ -0,0 +1,919 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2009-2011 Oliver Hader <oliver@typo3.org>
+*  All rights reserved
+*
+*  This script is part of the TYPO3 project. The TYPO3 project is
+*  free software; you can redistribute it and/or modify
+*  it under the terms of the GNU General Public License as published by
+*  the Free Software Foundation; either version 2 of the License, or
+*  (at your option) any later version.
+*
+*  The GNU General Public License can be found at
+*  http://www.gnu.org/copyleft/gpl.html.
+*
+*  This script is distributed in the hope that it will be useful,
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*  GNU General Public License for more details.
+*
+*  This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+
+/**
+ * Testcase for the "tslib_cObj" class in the TYPO3 Core.
+ *
+ * @package TYPO3
+ * @subpackage tslib
+ *
+ * @author Oliver Hader <oliver@typo3.org>
+ * @author Oliver Klee <typo3-coding@oliverklee.de>
+ */
+class tslib_contentTest extends tx_phpunit_testcase {
+       /**
+        * @var array
+        */
+       private $backupGlobalVariables;
+
+       /**
+        * @var tslib_cObj
+        */
+       private $cObj;
+
+       /**
+        * @var tslib_fe
+        */
+       private $tsfe;
+
+       /**
+        * @var t3lib_TStemplate
+        */
+       private $template;
+
+       /**
+        * @var array
+        */
+       private $typoScriptImage;
+
+       public function setUp() {
+               $this->backupGlobalVariables = array(
+                       '_GET' => $_GET,
+                       '_POST' => $_POST,
+                       '_SERVER' => $_SERVER,
+                       'TYPO3_CONF_VARS' => $GLOBALS['TYPO3_CONF_VARS'],
+               );
+
+               $this->template = $this->getMock(
+                       't3lib_TStemplate', array('getFileName', 'linkData')
+               );
+               $this->tsfe = $this->getMock('tslib_fe', array(), array(), '', FALSE);
+               $this->tsfe->tmpl = $this->template;
+               $this->tsfe->config = array();
+               $GLOBALS['TSFE'] = $this->tsfe;
+               $GLOBALS['TSFE']->csConvObj = new t3lib_cs();
+               $GLOBALS['TSFE']->renderCharset = 'utf-8';
+               $GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_utils'] = 'mbstring';
+
+               $className = 'tslib_cObj_' . uniqid('test');
+               eval('
+                       class ' . $className . ' extends tslib_cObj {
+                               public $stdWrapHookObjects = array();
+                               public $getImgResourceHookObjects;
+                       }
+               ');
+
+               $this->cObj = new $className();
+               $this->cObj->start(array(), 'tt_content');
+
+               $this->typoScriptImage = array(
+                       'file' => 'typo3/clear.gif',
+               );
+       }
+
+       public function tearDown() {
+               foreach ($this->backupGlobalVariables as $key => $data) {
+                       $GLOBALS[$key] = $data;
+               }
+
+               $GLOBALS['TSFE'] = NULL;
+
+               unset($this->cObj, $this->tsfe, $this->template, $this->typoScriptImage);
+       }
+
+
+       ////////////////////////
+       // Utitility functions
+       ////////////////////////
+
+       /**
+        * Converts the subject and the expected result into the target charset.
+        *
+        * @param string $charset the target charset
+        * @param string $subject the subject, will be modified
+        * @param string $expected the expected result, will be modified
+        */
+       protected function handleCharset($charset, &$subject, &$expected) {
+               $GLOBALS['TSFE']->renderCharset = $charset;
+               $subject = $GLOBALS['TSFE']->csConvObj->conv($subject, 'iso-8859-1', $charset);
+               $expected = $GLOBALS['TSFE']->csConvObj->conv($expected, 'iso-8859-1', $charset);
+       }
+
+
+       /////////////////////////////////////////////
+       // Tests concerning the getImgResource hook
+       /////////////////////////////////////////////
+
+       /**
+        * @test
+        */
+       public function getImgResourceHookGetsCalled() {
+               $this->template->expects($this->atLeastOnce())->method('getFileName')
+                       ->with('typo3/clear.gif')->will($this->returnValue('typo3/clear.gif'));
+
+               $className = uniqid('tx_coretest');
+               $getImgResourceHookMock = $this->getMock(
+                       'tslib_cObj_getImgResourceHook',
+                       array('getImgResourcePostProcess'),
+                       array(),
+                       $className
+               );
+
+               $getImgResourceHookMock->expects($this->once())->method('getImgResourcePostProcess')
+                       ->will($this->returnCallback(array($this, 'isGetImgResourceHookCalledCallback')));
+               $this->cObj->getImgResourceHookObjects = array($getImgResourceHookMock);
+
+               $this->cObj->IMAGE($this->typoScriptImage);
+       }
+
+       /**
+        * Handles the arguments that have been sent to the getImgResource hook.
+        *
+        * @return      array
+        *
+        * @see getImgResourceHookGetsCalled
+        */
+       public function isGetImgResourceHookCalledCallback() {
+               list($file, $fileArray, $imageResource, $parent) = func_get_args();
+
+               $this->assertEquals('typo3/clear.gif', $file);
+               $this->assertEquals('typo3/clear.gif', $imageResource['origFile']);
+               $this->assertTrue(is_array($fileArray));
+               $this->assertTrue($parent instanceof tslib_cObj);
+
+               return $imageResource;
+       }
+
+
+       //////////////////////////
+       // Tests concerning FORM
+       //////////////////////////
+
+       /**
+        * @test
+        */
+       public function formWithSecureFormMailEnabledDoesNotContainRecipientField() {
+               $GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail'] = TRUE;
+
+               $this->assertNotContains(
+                       'name="recipient',
+                       $this->cObj->FORM(
+                               array('recipient' => 'foo@bar.com', 'recipient.' => array()),
+                               array()
+                       )
+               );
+       }
+
+       /**
+        * @test
+        */
+       public function formWithSecureFormMailDisabledDoesNotContainRecipientField() {
+               $GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail'] = FALSE;
+
+               $this->assertContains(
+                       'name="recipient',
+                       $this->cObj->FORM(
+                               array('recipient' => 'foo@bar.com', 'recipient.' => array()),
+                               array()
+                       )
+               );
+       }
+
+
+       /////////////////////////////////////////
+       // Tests concerning getQueryArguments()
+       /////////////////////////////////////////
+
+       /**
+        * @test
+        */
+       public function getQueryArgumentsExcludesParameters() {
+               $_SERVER['QUERY_STRING'] =
+                       'key1=value1' .
+                       '&key2=value2' .
+                       '&key3[key31]=value31' .
+                       '&key3[key32][key321]=value321' .
+                       '&key3[key32][key322]=value322';
+
+               $getQueryArgumentsConfiguration = array();
+               $getQueryArgumentsConfiguration['exclude'] = array();
+               $getQueryArgumentsConfiguration['exclude'][] = 'key1';
+               $getQueryArgumentsConfiguration['exclude'][] = 'key3[key31]';
+               $getQueryArgumentsConfiguration['exclude'][] = 'key3[key32][key321]';
+               $getQueryArgumentsConfiguration['exclude'] = implode(',', $getQueryArgumentsConfiguration['exclude']);
+
+               $expectedResult = $this->rawUrlEncodeSquareBracketsInUrl('&key2=value2&key3[key32][key322]=value322');
+               $actualResult = $this->cObj->getQueryArguments($getQueryArgumentsConfiguration);
+               $this->assertEquals($expectedResult, $actualResult);
+       }
+
+       /**
+        * @test
+        */
+       public function getQueryArgumentsExcludesGetParameters() {
+               $_GET = array(
+                       'key1' => 'value1',
+                       'key2' => 'value2',
+                       'key3' => array(
+                               'key31' => 'value31',
+                               'key32' => array(
+                                       'key321' => 'value321',
+                                       'key322' => 'value322',
+                               ),
+                       ),
+               );
+
+               $getQueryArgumentsConfiguration = array();
+               $getQueryArgumentsConfiguration['method'] = 'GET';
+               $getQueryArgumentsConfiguration['exclude'] = array();
+               $getQueryArgumentsConfiguration['exclude'][] = 'key1';
+               $getQueryArgumentsConfiguration['exclude'][] = 'key3[key31]';
+               $getQueryArgumentsConfiguration['exclude'][] = 'key3[key32][key321]';
+               $getQueryArgumentsConfiguration['exclude'] = implode(',', $getQueryArgumentsConfiguration['exclude']);
+
+               $expectedResult = $this->rawUrlEncodeSquareBracketsInUrl('&key2=value2&key3[key32][key322]=value322');
+               $actualResult = $this->cObj->getQueryArguments($getQueryArgumentsConfiguration);
+               $this->assertEquals($expectedResult, $actualResult);
+       }
+
+       /**
+        * @test
+        */
+       public function getQueryArgumentsOverrulesSingleParameter() {
+               $_SERVER['QUERY_STRING'] = 'key1=value1';
+
+               $getQueryArgumentsConfiguration = array();
+
+               $overruleArguments = array(
+                               // Should be overriden
+                       'key1' => 'value1Overruled',
+                               // Shouldn't be set: Parameter doesn't exist in source array and is not forced
+                       'key2' => 'value2Overruled',
+               );
+
+               $expectedResult = '&key1=value1Overruled';
+               $actualResult = $this->cObj->getQueryArguments($getQueryArgumentsConfiguration, $overruleArguments);
+               $this->assertEquals($expectedResult, $actualResult);
+       }
+
+       /**
+        * @test
+        */
+       public function getQueryArgumentsOverrulesMultiDimensionalParameters() {
+               $_POST = array(
+                       'key1' => 'value1',
+                       'key2' => 'value2',
+                       'key3' => array(
+                               'key31' => 'value31',
+                               'key32' => array(
+                                       'key321' => 'value321',
+                                       'key322' => 'value322',
+                               ),
+                       ),
+               );
+
+               $getQueryArgumentsConfiguration = array();
+               $getQueryArgumentsConfiguration['method'] = 'POST';
+               $getQueryArgumentsConfiguration['exclude'] = array();
+               $getQueryArgumentsConfiguration['exclude'][] = 'key1';
+               $getQueryArgumentsConfiguration['exclude'][] = 'key3[key31]';
+               $getQueryArgumentsConfiguration['exclude'][] = 'key3[key32][key321]';
+               $getQueryArgumentsConfiguration['exclude'] = implode(',', $getQueryArgumentsConfiguration['exclude']);
+
+               $overruleArguments = array(
+                               // Should be overriden
+                       'key2' => 'value2Overruled',
+                       'key3' => array(
+                               'key32' => array(
+                                               // Shouldn't be set: Parameter is excluded and not forced
+                                       'key321' => 'value321Overruled',
+                                               // Should be overriden: Parameter is not excluded
+                                       'key322' => 'value322Overruled',
+                                               // Shouldn't be set: Parameter doesn't exist in source array and is not forced
+                                       'key323' => 'value323Overruled',
+                               ),
+                       ),
+               );
+
+               $expectedResult = $this->rawUrlEncodeSquareBracketsInUrl('&key2=value2Overruled&key3[key32][key322]=value322Overruled');
+               $actualResult = $this->cObj->getQueryArguments($getQueryArgumentsConfiguration, $overruleArguments);
+               $this->assertEquals($expectedResult, $actualResult);
+       }
+
+       /**
+        * @test
+        */
+       public function getQueryArgumentsOverrulesMultiDimensionalForcedParameters() {
+               $_SERVER['QUERY_STRING'] =
+                       'key1=value1' .
+                       '&key2=value2' .
+                       '&key3[key31]=value31' .
+                       '&key3[key32][key321]=value321' .
+                       '&key3[key32][key322]=value322';
+
+               $_POST = array(
+                       'key1' => 'value1',
+                       'key2' => 'value2',
+                       'key3' => array(
+                               'key31' => 'value31',
+                               'key32' => array(
+                                       'key321' => 'value321',
+                                       'key322' => 'value322',
+                               ),
+                       ),
+               );
+
+               $getQueryArgumentsConfiguration = array();
+               $getQueryArgumentsConfiguration['exclude'] = array();
+               $getQueryArgumentsConfiguration['exclude'][] = 'key1';
+               $getQueryArgumentsConfiguration['exclude'][] = 'key3[key31]';
+               $getQueryArgumentsConfiguration['exclude'][] = 'key3[key32][key321]';
+               $getQueryArgumentsConfiguration['exclude'][] = 'key3[key32][key322]';
+               $getQueryArgumentsConfiguration['exclude'] = implode(',', $getQueryArgumentsConfiguration['exclude']);
+
+               $overruleArguments = array(
+                               // Should be overriden
+                       'key2' => 'value2Overruled',
+                       'key3' => array(
+                               'key32' => array(
+                                               // Should be set: Parameter is excluded but forced
+                                       'key321' => 'value321Overruled',
+                                               // Should be set: Parameter doesn't exist in source array but is forced
+                                       'key323' => 'value323Overruled',
+                               ),
+                       ),
+               );
+
+               $expectedResult = $this->rawUrlEncodeSquareBracketsInUrl('&key2=value2Overruled&key3[key32][key321]=value321Overruled&key3[key32][key323]=value323Overruled');
+               $actualResult = $this->cObj->getQueryArguments($getQueryArgumentsConfiguration, $overruleArguments, TRUE);
+               $this->assertEquals($expectedResult, $actualResult);
+
+               $getQueryArgumentsConfiguration['method'] = 'POST';
+               $actualResult = $this->cObj->getQueryArguments($getQueryArgumentsConfiguration, $overruleArguments, TRUE);
+               $this->assertEquals($expectedResult, $actualResult);
+       }
+
+       /**
+        * Encodes square brackets in URL.
+        *
+        * @param string $string
+        * @return string
+        */
+       private function rawUrlEncodeSquareBracketsInUrl($string) {
+               return str_replace(
+                       array('[', ']'),
+                       array('%5B', '%5D'),
+                       $string
+               );
+       }
+
+
+       //////////////////////////////
+       // Tests concerning crop
+       //////////////////////////////
+
+       /**
+        * @test
+        */
+       public function cropIsMultibyteSafe() {
+               $this->assertEquals('бла', $this->cObj->crop('бла', '3|...'));
+       }
+
+       //////////////////////////////
+       // Tests concerning cropHTML
+       //////////////////////////////
+
+       /**
+        * This is the data provider for the tests of crop and cropHTML below. It provides all combinations
+        * of charset, text type, and configuration options to be tested.
+        *
+        * @return array two-dimensional array with the second level like this:
+        *               0 => the settings for the crop function, for example "-58|..."
+        *               1 => the string to crop
+        *               2 => the expected cropped result
+        *               3 => the charset that will be set as renderCharset
+        *
+        * @see cropHtmlWithDataProvider
+        */
+       public function cropHtmlDataProvider() {
+               $plainText = 'Kasper Sk' . chr(229) . 'rh' . chr(248) .
+                       'j implemented the original version of the crop function.';
+               $textWithMarkup = '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' .
+                       chr(229) . 'rh' . chr(248) . 'j</a>' .
+                       ' implemented</strong> the original version of the crop function.';
+               $textWithEntities = 'Kasper Sk&aring;rh&oslash;j implemented the; original ' .
+                       'version of the crop function.';
+
+               $charsets = array('iso-8859-1', 'utf-8', 'ascii', 'big5');
+
+               $data = array();
+               foreach ($charsets as $charset) {
+                       $data = array_merge($data, array(
+                               $charset . ' plain text; 11|...' => array(
+                                       '11|...', $plainText, 'Kasper Sk' . chr(229) . 'r...', $charset
+                               ),
+                               $charset . ' plain text; -58|...' => array(
+                                       '-58|...', $plainText, '...h' . chr(248) . 'j implemented the original version of the crop function.', $charset
+                               ),
+                               $charset . ' plain text; 4|...|1' => array(
+                                       '4|...|1', $plainText, 'Kasp...', $charset
+                               ),
+                               $charset . ' plain text; 20|...|1' => array(
+                                       '20|...|1', $plainText, 'Kasper Sk' . chr(229) . 'rh' . chr(248) . 'j...', $charset
+                               ),
+                               $charset . ' plain text; -5|...|1' => array(
+                                       '-5|...|1', $plainText, '...tion.', $charset
+                               ),
+                               $charset . ' plain text; -49|...|1' => array(
+                                       '-49|...|1', $plainText, '...the original version of the crop function.', $charset
+                               ),
+                               $charset . ' text with markup; 11|...' => array(
+                                       '11|...', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) . 'r...</a></strong>', $charset
+                               ),
+                               $charset . ' text with markup; 13|...' => array(
+                                       '13|...', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) . 'rh' . chr(248) . '...</a></strong>', $charset
+                               ),
+                               $charset . ' text with markup; 14|...' => array(
+                                       '14|...', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) . 'rh' . chr(248) . 'j</a>...</strong>', $charset
+                               ),
+                               $charset . ' text with markup; 15|...' => array(
+                                       '15|...', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) . 'rh' . chr(248) . 'j</a> ...</strong>', $charset
+                               ),
+                               $charset . ' text with markup; 29|...' => array(
+                                       '29|...', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) . 'rh' . chr(248) . 'j</a> implemented</strong> th...', $charset
+                               ),
+                               $charset . ' text with markup; -58|...' => array(
+                                       '-58|...', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">...h' . chr(248) . 'j</a> implemented</strong> the original version of the crop function.', $charset
+                               ),
+                               $charset . ' text with markup 4|...|1' => array(
+                                       '4|...|1', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasp...</a></strong>', $charset
+                               ),
+                               $charset . ' text with markup; 11|...|1' => array(
+                                       '11|...|1', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper...</a></strong>', $charset
+                               ),
+                               $charset . ' text with markup; 13|...|1' => array(
+                                       '13|...|1', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper...</a></strong>', $charset
+                               ),
+                               $charset . ' text with markup; 14|...|1' => array(
+                                       '14|...|1', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) . 'rh' . chr(248) . 'j</a>...</strong>', $charset
+                               ),
+                               $charset . ' text with markup; 15|...|1' => array(
+                                       '15|...|1', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) . 'rh' . chr(248) . 'j</a>...</strong>', $charset
+                               ),
+                               $charset . ' text with markup; 29|...|1' => array(
+                                       '29|...|1', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) . 'rh' . chr(248) . 'j</a> implemented</strong>...', $charset
+                               ),
+                               $charset . ' text with markup; -66|...|1' => array(
+                                       '-66|...|1', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">...Sk' . chr(229) . 'rh' . chr(248) . 'j</a> implemented</strong> the original version of the crop function.', $charset
+                               ),
+                               $charset . ' text with entities 9|...' => array(
+                                       '9|...', $textWithEntities, 'Kasper Sk...', $charset
+                               ),
+                               $charset . ' text with entities 10|...' => array(
+                                       '10|...', $textWithEntities, 'Kasper Sk&aring;...', $charset
+                               ),
+                               $charset . ' text with entities 11|...' => array(
+                                       '11|...', $textWithEntities, 'Kasper Sk&aring;r...', $charset
+                               ),
+                               $charset . ' text with entities 13|...' => array(
+                                       '13|...', $textWithEntities, 'Kasper Sk&aring;rh&oslash;...', $charset
+                               ),
+                               $charset . ' text with entities 14|...' => array(
+                                       '14|...', $textWithEntities, 'Kasper Sk&aring;rh&oslash;j...', $charset
+                               ),
+                               $charset . ' text with entities 15|...' => array(
+                                       '15|...', $textWithEntities, 'Kasper Sk&aring;rh&oslash;j ...', $charset
+                               ),
+                               $charset . ' text with entities 16|...' => array(
+                                       '16|...', $textWithEntities, 'Kasper Sk&aring;rh&oslash;j i...', $charset
+                               ),
+                               $charset . ' text with entities -57|...' => array(
+                                       '-57|...', $textWithEntities, '...j implemented the; original version of the crop function.', $charset
+                               ),
+                               $charset . ' text with entities -58|...' => array(
+                                       '-58|...', $textWithEntities, '...&oslash;j implemented the; original version of the crop function.', $charset
+                               ),
+                               $charset . ' text with entities -59|...' => array(
+                                       '-59|...', $textWithEntities, '...h&oslash;j implemented the; original version of the crop function.', $charset
+                               ),
+                               $charset . ' text with entities 4|...|1' => array(
+                                       '4|...|1', $textWithEntities, 'Kasp...', $charset
+                               ),
+                               $charset . ' text with entities 9|...|1' => array(
+                                       '9|...|1', $textWithEntities, 'Kasper...', $charset
+                               ),
+                               $charset . ' text with entities 10|...|1' => array(
+                                       '10|...|1', $textWithEntities, 'Kasper...', $charset
+                               ),
+                               $charset . ' text with entities 11|...|1' => array(
+                                       '11|...|1', $textWithEntities, 'Kasper...', $charset
+                               ),
+                               $charset . ' text with entities 13|...|1' => array(
+                                       '13|...|1', $textWithEntities, 'Kasper...', $charset
+                               ),
+                               $charset . ' text with entities 14|...|1' => array(
+                                       '14|...|1', $textWithEntities, 'Kasper Sk&aring;rh&oslash;j...', $charset
+                               ),
+                               $charset . ' text with entities 15|...|1' => array(
+                                       '15|...|1', $textWithEntities, 'Kasper Sk&aring;rh&oslash;j...', $charset
+                               ),
+                               $charset . ' text with entities 16|...|1' => array(
+                                       '16|...|1', $textWithEntities, 'Kasper Sk&aring;rh&oslash;j...', $charset
+                               ),
+                               $charset . ' text with entities -57|...|1' => array(
+                                       '-57|...|1', $textWithEntities, '...implemented the; original version of the crop function.', $charset
+                               ),
+                               $charset . ' text with entities -58|...|1' => array(
+                                       '-58|...|1', $textWithEntities, '...implemented the; original version of the crop function.', $charset
+                               ),
+                               $charset . ' text with entities -59|...|1' => array(
+                                       '-59|...|1', $textWithEntities, '...implemented the; original version of the crop function.', $charset
+                               ),
+                       ));
+               }
+               return $data;
+       }
+
+       /**
+        * Checks if stdWrap.cropHTML works with plain text cropping from left
+        *
+        * @test
+        *
+        * @dataProvider cropHtmlDataProvider
+        *
+        * @param string $settings
+        *        the settings for the crop function, for example "-58|..."
+        * @param string $subject the string to crop
+        * @param string $expected the expected cropped result
+        * @param string $charset the charset that will be set as renderCharset
+        */
+       public function cropHtmlWithDataProvider($settings, $subject, $expected, $charset) {
+               $this->handleCharset($charset, $subject, $expected);
+
+               $this->assertEquals(
+                       $expected,
+                       $this->cObj->cropHTML($subject, $settings),
+                       'cropHTML failed with settings: "' . $settings . '" and charset "' . $charset . '"'
+               );
+       }
+
+       /**
+        * Checks if stdWrap.cropHTML works with a complex content with many tags. Currently cropHTML
+        * counts multiple invisible characters not as one (as the browser will output the content).
+        *
+        * @test
+        */
+       public function cropHtmlWorksWithComplexContent() {
+               $GLOBALS['TSFE']->renderCharset = 'iso-8859-1';
+               $subject = '
+<h1>Blog Example</h1>
+<hr>
+<div class="csc-header csc-header-n1">
+       <h2 class="csc-firstHeader">Welcome to Blog #1</h2>
+</div>
+<p class="bodytext">
+       A blog about TYPO3 extension development. In order to start blogging, read the <a href="#">Help section</a>. If you have any further questions, feel free to contact the administrator John Doe (<a href="mailto:john.doe@example.com">john.doe@example.com)</a>.
+</p>
+<div class="tx-blogexample-list-container">
+       <p class="bodytext">
+               Below are the most recent posts:
+       </p>
+       <ul>
+               <li>
+                       <h3>
+                               <a href="index.php?id=99&amp;tx_blogexample_pi1[post][uid]=211&amp;tx_blogexample_pi1[blog]=&amp;tx_blogexample_pi1[action]=show&amp;tx_blogexample_pi1[controller]=Post&amp;cHash=003b0131ed">The Post #1</a>
+                       </h3>
+                       <p class="bodytext">
+                               Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut...
+                       </p>
+                       <p class="metadata">
+                               Published on 26.08.2009 by Jochen Rau
+                       </p>
+                       <p>
+                               Tags: [MVC]&nbsp;[Domain Driven Design]&nbsp;<br>
+                               <a href="index.php?id=99&amp;tx_blogexample_pi1[post][uid]=211&amp;tx_blogexample_pi1[action]=show&amp;tx_blogexample_pi1[controller]=Post&amp;cHash=f982643bc3">read more &gt;&gt;</a><br>
+                               <a href="index.php?id=99&amp;tx_blogexample_pi1[post][uid]=211&amp;tx_blogexample_pi1[blog][uid]=70&amp;tx_blogexample_pi1[action]=edit&amp;tx_blogexample_pi1[controller]=Post&amp;cHash=5b481bc8f0">Edit</a>&nbsp;<a href="index.php?id=99&amp;tx_blogexample_pi1[post][uid]=211&amp;tx_blogexample_pi1[blog][uid]=70&amp;tx_blogexample_pi1[action]=delete&amp;tx_blogexample_pi1[controller]=Post&amp;cHash=4e52879656">Delete</a>
+                       </p>
+               </li>
+       </ul>
+       <p>
+               <a href="index.php?id=99&amp;tx_blogexample_pi1[blog][uid]=70&amp;tx_blogexample_pi1[action]=new&amp;tx_blogexample_pi1[controller]=Post&amp;cHash=2718a4b1a0">Create a new Post</a>
+       </p>
+</div>
+<hr>
+<p>
+       ? TYPO3 Association
+</p>
+';
+
+               $result = $this->cObj->cropHTML($subject, '300');
+               $expected = '
+<h1>Blog Example</h1>
+<hr>
+<div class="csc-header csc-header-n1">
+       <h2 class="csc-firstHeader">Welcome to Blog #1</h2>
+</div>
+<p class="bodytext">
+       A blog about TYPO3 extension development. In order to start blogging, read the <a href="#">Help section</a>. If you have any further questions, feel free to contact the administrator John Doe (<a href="mailto:john.doe@example.com">john.doe@example.com)</a>.
+</p>
+<div class="tx-blogexample-list-container">
+       <p class="bodytext">
+               Below are the most recent posts:
+       </p>
+       <ul>
+               <li>
+                       <h3>
+                               <a href="index.php?id=99&amp;tx_blogexample_pi1[post][uid]=211&amp;tx_blogexample_pi1[blog]=&amp;tx_blogexample_pi1[action]=show&amp;tx_blogexample_pi1[controller]=Post&amp;cHash=003b0131ed">The Pos</a></h3></li></ul></div>';
+               $this->assertEquals($expected, $result);
+
+               $result = $this->cObj->cropHTML($subject, '-100');
+               $expected = '<div class="tx-blogexample-list-container"><ul><li><p>Design]&nbsp;<br>
+                               <a href="index.php?id=99&amp;tx_blogexample_pi1[post][uid]=211&amp;tx_blogexample_pi1[action]=show&amp;tx_blogexample_pi1[controller]=Post&amp;cHash=f982643bc3">read more &gt;&gt;</a><br>
+                               <a href="index.php?id=99&amp;tx_blogexample_pi1[post][uid]=211&amp;tx_blogexample_pi1[blog][uid]=70&amp;tx_blogexample_pi1[action]=edit&amp;tx_blogexample_pi1[controller]=Post&amp;cHash=5b481bc8f0">Edit</a>&nbsp;<a href="index.php?id=99&amp;tx_blogexample_pi1[post][uid]=211&amp;tx_blogexample_pi1[blog][uid]=70&amp;tx_blogexample_pi1[action]=delete&amp;tx_blogexample_pi1[controller]=Post&amp;cHash=4e52879656">Delete</a>
+                       </p>
+               </li>
+       </ul>
+       <p>
+               <a href="index.php?id=99&amp;tx_blogexample_pi1[blog][uid]=70&amp;tx_blogexample_pi1[action]=new&amp;tx_blogexample_pi1[controller]=Post&amp;cHash=2718a4b1a0">Create a new Post</a>
+       </p>
+</div>
+<hr>
+<p>
+       ? TYPO3 Association
+</p>
+';
+               $this->assertEquals(
+                       $expected,
+                       $result
+               );
+       }
+
+       /**
+        * @return array
+        */
+       public function stdWrap_roundDataProvider() {
+               return array(
+                       'rounding off without any configuration' => array(
+                               1.123456789,
+                               array(
+                               ),
+                               1
+                       ),
+                       'rounding up without any configuration' => array(
+                               1.523456789,
+                               array(
+                               ),
+                               2
+                       ),
+                       'regular rounding (off) to two decimals' => array(
+                               0.123456789,
+                               array(
+                                       'decimals' => 2
+                               ),
+                               0.12
+                       ),
+                       'regular rounding (up) to two decimals' => array(
+                               0.1256789,
+                               array(
+                                       'decimals' => 2
+                               ),
+                               0.13
+                       ),
+                       'rounding up to integer with type ceil' => array(
+                               0.123456789,
+                               array(
+                                       'roundType' => 'ceil'
+                               ),
+                               1
+                       ),
+                       'rounding down to integer with type floor' => array(
+                               2.3481,
+                               array(
+                                       'roundType' => 'floor'
+                               ),
+                               2
+                       )
+               );
+       }
+
+       /**
+        * Test for the stdWrap function "round"
+        *
+        * @param float $float
+        * @param array $conf
+        * @param float $expected
+        * @return void
+        *
+        * @dataProvider stdWrap_roundDataProvider
+        * @test
+        */
+       public function stdWrap_round($float, $conf, $expected) {
+               $conf = array(
+                       'round.' => $conf
+               );
+               $result = $this->cObj->stdWrap_round($float, $conf);
+               $this->assertEquals($expected, $result);
+       }
+
+       /**
+        * Data provider for the hash test
+        *
+        * @return array multi-dimensional array with the second level like this:
+        *               0 => the plain text
+        *               1 => the conf array for the hash stdWrap function
+        *               2 => the expected result
+        *
+        * @see hash
+        */
+       public function hashDataProvider() {
+               $data = array(
+                       'testing md5' => array(
+                               'joh316',
+                               array(
+                                       'hash' => 'md5'
+                               ),
+                               'bacb98acf97e0b6112b1d1b650b84971'
+                       ),
+                       'testing sha1' => array(
+                               'joh316',
+                               array(
+                                       'hash' => 'sha1'
+                               ),
+                               '063b3d108bed9f88fa618c6046de0dccadcf3158'
+                       ),
+                       'testing non-existing hashing algorithm' => array(
+                               'joh316',
+                               array(
+                                       'hash' => 'non-existing'
+                               ),
+                               ''
+                       ),
+                       'testing stdWrap capability' => array(
+                               'joh316',
+                               array(
+                                       'hash.' => array(
+                                               'cObject' => 'TEXT',
+                                               'cObject.' => array(
+                                                       'value' => 'md5'
+                                               )
+                                       )
+                               ),
+                               'bacb98acf97e0b6112b1d1b650b84971'
+                       )
+               );
+               return $data;
+       }
+
+       /**
+        * Test for the stdWrap function "hash"
+        *
+        * @param string $text
+        * @param array $conf
+        * @param string $expected
+        * @return void
+        *
+        * @dataProvider hashDataProvider
+        * @test
+        */
+       public function stdWrap_hash($text, array $conf, $expected) {
+               $result = $this->cObj->stdWrap_hash($text, $conf);
+               $this->assertEquals($expected, $result);
+       }
+
+       /**
+        * Data provider for the numberFormat test
+        *
+        * @return array multi-dimensional array with the second level like this:
+        *               0 => the input float number
+        *               1 => the conf array for the numberFormat stdWrap function
+        *               2 => the expected result
+        *
+        * @see numberFormat
+        */
+       public function numberFormatDataProvider() {
+               $data = array(
+                       'testing decimals' => array(
+                               0.8,
+                               array(
+                                       'decimals' => 2
+                               ),
+                               '0.80'
+                       ),
+                       'testing dec_point' => array(
+                               0.8,
+                               array(
+                                       'decimals' => 1,
+                                       'dec_point' => ','
+                               ),
+                               '0,8'
+                       ),
+                       'testing thousands_sep' => array(
+                               999.99,
+                               array(
+                                       'decimals' => 0,
+                                       'thousands_sep.' => array(
+                                               'char' => 46
+                                       )
+                               ),
+                               '1.000'
+                       ),
+                       'testing mixture' => array(
+                               1281731.45,
+                               array(
+                                       'decimals' => 1,
+                                       'dec_point.' => array(
+                                               'char' => 44
+                                       ),
+                                       'thousands_sep.' => array(
+                                               'char' => 46
+                                       )
+                               ),
+                               '1.281.731,5'
+                       )
+               );
+               return $data;
+       }
+
+       /**
+        * Check if stdWrap.numberFormat and all of its properties work properly
+        *
+        * @dataProvider numberFormatDataProvider
+        *
+        * @test
+        */
+       public function numberFormat($float, $formatConf, $expected) {
+               $result = $this->cObj->numberFormat($float, $formatConf);
+               $this->assertEquals($expected, $result);
+       }
+
+       /**
+        * Data provider for the replacement test
+        *
+        * @return array multi-dimensional array with the second level like this:
+        *               0 => the input text
+        *               1 => the conf array for the replacement stdWrap function
+        *               2 => the expected result
+        *
+        * @see replacement
+        */
+       public function replacementDataProvider() {
+               $data = array(
+                       'multiple replacements, including regex' => array(
+                               'There_is_a_cat,_a_dog_and_a_tiger_in_da_hood!_Yeah!',
+                               array('replacement.' =>
+                                       array(
+                                               '120.' => array(
+                                                       'search' => 'in da hood',
+                                                       'replace' => 'around the block',
+                                               ),
+                                               '20.' => array(
+                                                       'search' => '_',
+                                                       'replace.' => array('char' => '32'),
+                                               ),
+                                               '130.' => array(
+                                                       'search' => '#a (Cat|Dog|Tiger)#i',
+                                                       'replace' => 'an animal',
+                                                       'useRegExp' => '1',
+                                               ),
+                                       ),
+                               ),
+                               'There is an animal, an animal and an animal around the block! Yeah!'
+                       ),
+               );
+               return $data;
+       }
+
+       /**
+        * Check if stdWrap.replacement and all of its properties work properly
+        *
+        * @dataProvider replacementDataProvider
+        *
+        * @test
+        */
+       public function replacement($input, $conf, $expected) {
+               $result = $this->cObj->stdWrap_replacement($input, $conf);
+               $this->assertEquals($expected, $result);
+       }
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/cms/tests/tslib/class.tslib_feTest.php b/typo3/sysext/cms/tests/tslib/class.tslib_feTest.php
new file mode 100644 (file)
index 0000000..8281851
--- /dev/null
@@ -0,0 +1,239 @@
+<?php
+/***************************************************************
+* Copyright notice
+*
+* (c) 2009-2011 Oliver Klee (typo3-coding@oliverklee.de)
+* All rights reserved
+*
+* This script is part of the TYPO3 project. The TYPO3 project is
+* free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2 of the License, or
+* (at your option) any later version.
+*
+* The GNU General Public License can be found at
+* http://www.gnu.org/copyleft/gpl.html.
+*
+* This script is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+
+/**
+ * Testcase for the "tslib_fe" class in the TYPO3 Core.
+ *
+ * @package TYPO3
+ * @subpackage tslib
+ *
+ * @author Oliver Klee <typo3-coding@oliverklee.de>
+ */
+class tslib_feTest extends tx_phpunit_testcase {
+       /**
+        * @var tslib_fe
+        */
+       private $fixture;
+
+       public function setUp() {
+                       // This creates an instance of the class without calling the
+                       // original constructor.
+               $className = uniqid('tslib_fe');
+               eval(
+                       'class ' . $className . ' extends tslib_fe {' .
+                       'public function ' . $className . '() {}' .
+
+                       'public function roundTripCryptString($string) {' .
+                       'return parent::roundTripCryptString($string);' .
+                       '}' .
+
+                       'public function stripIPv4($strIP) {' .
+                       'return parent::stripIPv4($strIP);' .
+                       '}' .
+
+                       'public function stripIPv6($strIP) {' .
+                       'return parent::stripIPv6($strIP);' .
+                       '}' .
+
+                       '}'
+               );
+
+               $this->fixture = new $className();
+               $this->fixture->TYPO3_CONF_VARS = $GLOBALS['TYPO3_CONF_VARS'];
+               $this->fixture->TYPO3_CONF_VARS['SYS']['encryptionKey']
+                       = '170928423746123078941623042360abceb12341234231';
+       }
+
+       public function tearDown() {
+               unset($this->fixture);
+       }
+
+
+       ////////////////////////////////
+       // Tests concerning codeString
+       ////////////////////////////////
+
+       /**
+        * @test
+        */
+       public function codeStringForNonEmptyStringReturns10CharacterHashAndCodedString() {
+               $this->assertRegExp(
+                       '/^[0-9a-f]{10}:[a-zA-Z0-9+=\/]+$/',
+                       $this->fixture->codeString('Hello world!')
+               );
+       }
+
+       /**
+        * @test
+        */
+       public function decodingCodedStringReturnsOriginalString() {
+               $clearText = 'Hello world!';
+
+               $this->assertEquals(
+                       $clearText,
+                       $this->fixture->codeString(
+                               $this->fixture->codeString($clearText), TRUE
+                       )
+               );
+       }
+
+
+       //////////////////////
+       // Tests concerning sL
+       //////////////////////
+
+       /**
+        * @test
+        */
+       public function localizationReturnsUnchangedStringIfNotLocallangLabel() {
+               $string = uniqid();
+               $this->assertEquals($string, $this->fixture->sL($string));
+       }
+
+
+       //////////////////////////////////////////
+       // Tests concerning roundTripCryptString
+       //////////////////////////////////////////
+
+       /**
+        * @test
+        */
+       public function roundTripCryptStringCreatesStringWithSameLengthAsInputString() {
+               $clearText = 'Hello world!';
+
+               $this->assertEquals(
+                       strlen($clearText),
+                       strlen($this->fixture->roundTripCryptString($clearText))
+               );
+       }
+
+       /**
+        * @test
+        */
+       public function roundTripCryptStringCreatesResultDifferentFromInputString() {
+               $clearText = 'Hello world!';
+
+               $this->assertNotEquals(
+                       $clearText,
+                       $this->fixture->roundTripCryptString($clearText)
+               );
+       }
+
+       /**
+        * @test
+        */
+       public function roundTripCryptStringAppliedTwoTimesReturnsOriginalString() {
+               $clearText = 'Hello world!';
+
+               $this->assertEquals(
+                       $clearText,
+                       $this->fixture->roundTripCryptString(
+                               $this->fixture->roundTripCryptString($clearText)
+                       )
+               );
+       }
+
+       //////////////////////////////////////
+       // Tests concerning stat-anonymization
+       //////////////////////////////////////
+
+       /**
+        * Data provider for stripIPv6Correct
+        *
+        * @return array Data sets
+        */
+       public static function stripIPv4DataProviderCorrect() {
+               return array(
+                       'empty address, prefix-length 24' => array('0.0.0.0', '24', '0.0.0.0'),
+                       'normal address 1, prefix-length 1' => array('1.2.3.4', '1', '0.0.0.0'),
+                       'normal address 2, prefix-length 24' => array('192.168.5.79', '24', '192.168.5.0'),
+                       'normal address 2, prefix-length 30' => array('192.168.5.79', '30', '192.168.5.76'),
+                               // test for no anonymization; full prefix-length
+                       'normal address 2, prefix-length 32' => array('192.168.5.79', '32', '192.168.5.79'),
+                               // test for full anonymization; full prefix-length
+                       'normal address 2, prefix-length 0' => array('192.168.5.79', '0', '0.0.0.0'),
+               );
+       }
+
+       /**
+        * @test
+        * @dataProvider stripIPv4DataProviderCorrect
+        */
+       public function stripIPv4Correct($address, $prefixLength, $anonymized) {
+               $oldConfig = $this->fixture->config;
+
+               $this->fixture->config = array('config' =>
+                       array('stat_IP_anonymize' => '1',
+                               'stat_IP_anonymize_mask_ipv4' => $prefixLength
+                       )
+               );
+
+               $this->assertEquals(
+                       $this->fixture->stripIPv4($address),
+                       $anonymized
+               );
+               $this->fixture->config = $oldConfig;
+       }
+
+       /**
+        * Data provider for stripIPv6Correct
+        *
+        * @return array Data sets
+        */
+       public static function stripIPv6DataProviderCorrect() {
+               return array(
+                       'empty address, prefix-length 96' => array('::', '96', '::'),
+                       'normal address 1, prefix-length 1' => array('1:2:3::4', '1', '::'),
+                       'normal address 2, prefix-length 4' => array('ffff::9876', '4', 'f000::'),
+                       'normal address 2, prefix-length 1' => array('ffff::9876', '1', '8000::'),
+                       'normal address 3, prefix-length 96' => array('abc:def::9876', '96', 'abc:def::'),
+                       'normal address 3, prefix-length 120' => array('abc:def::9876', '120', 'abc:def::9800'),
+                               // test for no anonymization; full prefix-length
+                       'normal address 3, prefix-length 128' => array('abc:def::9876', '128', 'abc:def::9876'),
+                               // test for full anonymization
+                       'normal address 3, prefix-length 0' => array('abc:def::9876', '0', '::'),
+               );
+       }
+
+       /**
+        * @test
+        * @dataProvider stripIPv6DataProviderCorrect
+        */
+       public function stripIPv6Correct($address, $prefixLength, $anonymized) {
+               $oldConfig = $this->fixture->config;
+
+               $this->fixture->config = array('config' =>
+                       array('stat_IP_anonymize' => '1',
+                               'stat_IP_anonymize_mask_ipv6' => $prefixLength
+                       )
+               );
+
+               $this->assertEquals(
+                       $this->fixture->stripIPv6($address),
+                       $anonymized
+               );
+               $this->fixture->config = $oldConfig;
+       }
+}
+?>
\ No newline at end of file