[BUGFIX] Fix frontend unit tests
authorWouter Wolters <typo3@wouterwolters.nl>
Sat, 25 Aug 2012 18:57:26 +0000 (20:57 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Tue, 28 Aug 2012 07:43:55 +0000 (09:43 +0200)
Move and stabilize EXT:frontend unit tests and add them
to travis testsuites.

Change-Id: Id3ade83bc54e3ba6ed80e435671954bb7c4f9482
Resolves: #40209
Related: #40095
Releases: 6.0
Reviewed-on: http://review.typo3.org/14091
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
15 files changed:
tests/Build/UnitTests.xml
typo3/sysext/cms/tests/fixtures/renderedPage.html [deleted file]
typo3/sysext/cms/tests/tslib/class.tslib_adminpanelTest.php [deleted file]
typo3/sysext/cms/tests/tslib/class.tslib_contentTest.php [deleted file]
typo3/sysext/cms/tests/tslib/class.tslib_feTest.php [deleted file]
typo3/sysext/cms/tests/tslib/class.tslib_menuTest.php [deleted file]
typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
typo3/sysext/frontend/Tests/Unit/AdminPanelTest.php [deleted file]
typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php [new file with mode: 0644]
typo3/sysext/frontend/Tests/Unit/ContentObject/Menu/AbstractMenuContentObjectTest.php
typo3/sysext/frontend/Tests/Unit/ContentTest.php [deleted file]
typo3/sysext/frontend/Tests/Unit/Controller/Fixtures/renderedPage.html [new file with mode: 0644]
typo3/sysext/frontend/Tests/Unit/Controller/TypoScriptFrontentControllerTest.php [new file with mode: 0644]
typo3/sysext/frontend/Tests/Unit/FrontendTest.php [deleted file]
typo3/sysext/frontend/Tests/Unit/View/AdminPanelViewTest.php [new file with mode: 0644]

index eb33083..afcca20 100644 (file)
@@ -19,6 +19,9 @@
                <testsuite name="EXT:backend Tests">
                        <directory>../../typo3/sysext/backend/Tests/Unit/</directory>
                </testsuite>
+               <testsuite name="EXT:frontend Tests">
+                       <directory>../../typo3/sysext/frontend/Tests/Unit/</directory>
+               </testsuite>
                <testsuite name="Core Tests">
                        <directory>../../tests/Unit/</directory>
                </testsuite>
diff --git a/typo3/sysext/cms/tests/fixtures/renderedPage.html b/typo3/sysext/cms/tests/fixtures/renderedPage.html
deleted file mode 100644 (file)
index cab1e65..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-<!DOCTYPE html
-       PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<html lang="en">
-<head>
-
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
-<!-- 
-       This website is powered by TYPO3 - inspiring people to share!
-       TYPO3 is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.
-       TYPO3 is copyright 1998-2012 of Kasper Skaarhoj. Extensions are copyright of their respective owners.
-       Information and contribution at http://typo3.org/
--->
-
-
-
-<title>powermail</title>
-<meta name="generator" content="TYPO3 6.0 CMS">
-
-<link rel="stylesheet" type="text/css" href="typo3temp/stylesheet_427bb03fe1.css?1334416344" media="all">
-
-
-
-<script src="typo3temp/javascript_175aa1ef20.js?1340313498" type="text/javascript"></script>
-
-
-<!--HD_679b52796e75d474ccbbed486b6837ab-->
-</head>
-<body>
-<!--TDS_679b52796e75d474ccbbed486b6837ab-->
-
-       <!--  CONTENT ELEMENT, uid:65/login [begin] -->
-               <div id="c65" class="csc-default csc-space-before- csc-space-after-"><!--INT_SCRIPT.13e1737dd0938292520612f3088602ba--></div>
-       <!--  CONTENT ELEMENT, uid:65/login [end] -->
-
-
-<!--FD_679b52796e75d474ccbbed486b6837ab-->
-</body>
-</html>
\ 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
deleted file mode 100644 (file)
index ad701e1..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-/*
- * @deprecated since 6.0, the classname tslib_AdminPanelTest and this file is obsolete
- * and will be removed by 7.0. The class was renamed and is now located at:
- * typo3/sysext/frontend/Tests/Unit/AdminPanelTest.php
- */
-require_once \TYPO3\CMS\Core\Extension\ExtensionManager::extPath('frontend') . 'Tests/Unit/AdminPanelTest.php';
-?>
\ 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
deleted file mode 100644 (file)
index 8686af1..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-/*
- * @deprecated since 6.0, the classname tslib_contentTest and this file is obsolete
- * and will be removed by 7.0. The class was renamed and is now located at:
- * typo3/sysext/frontend/Tests/Unit/ContentTest.php
- */
-require_once \TYPO3\CMS\Core\Extension\ExtensionManager::extPath('frontend') . 'Tests/Unit/ContentTest.php';
-?>
\ 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
deleted file mode 100644 (file)
index 3203cbc..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-/*
- * @deprecated since 6.0, the classname tslib_feTest and this file is obsolete
- * and will be removed by 7.0. The class was renamed and is now located at:
- * typo3/sysext/frontend/Tests/Unit/FrontendTest.php
- */
-require_once \TYPO3\CMS\Core\Extension\ExtensionManager::extPath('frontend') . 'Tests/Unit/FrontendTest.php';
-?>
\ No newline at end of file
diff --git a/typo3/sysext/cms/tests/tslib/class.tslib_menuTest.php b/typo3/sysext/cms/tests/tslib/class.tslib_menuTest.php
deleted file mode 100644 (file)
index 412f480..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-/*
- * @deprecated since 6.0, the classname tslib_menuTest and this file is obsolete
- * and will be removed by 7.0. The class was renamed and is now located at:
- * typo3/sysext/frontend/Tests/Unit/ContentObject/Menu/AbstractMenuContentObjectTest.php
- */
-require_once \TYPO3\CMS\Core\Extension\ExtensionManager::extPath('frontend') . 'Tests/Unit/ContentObject/Menu/AbstractMenuContentObjectTest.php';
-?>
\ No newline at end of file
index 259da32..e237d54 100644 (file)
@@ -3389,7 +3389,7 @@ class TypoScriptFrontendController {
                $this->content = str_replace(('<!--HD_' . $this->config['INTincScript_ext']['divKey']) . '-->', $this->convOutputCharset(implode(LF, $this->additionalHeaderData), 'HD'), $this->content);
                $this->content = str_replace(('<!--FD_' . $this->config['INTincScript_ext']['divKey']) . '-->', $this->convOutputCharset(implode(LF, $this->additionalFooterData), 'FD'), $this->content);
                $this->content = str_replace(('<!--TDS_' . $this->config['INTincScript_ext']['divKey']) . '-->', $this->convOutputCharset($this->divSection, 'TDS'), $this->content);
-               $this->content = $this->pageRenderer->renderJavaScriptAndCssForProcessingOfUncachedContentObjects($this->content, $this->config['INTincScript_ext']['divKey']);
+               $this->content = $this->getPageRenderer()->renderJavaScriptAndCssForProcessingOfUncachedContentObjects($this->content, $this->config['INTincScript_ext']['divKey']);
                $this->setAbsRefPrefix();
                $GLOBALS['TT']->pull();
        }
diff --git a/typo3/sysext/frontend/Tests/Unit/AdminPanelTest.php b/typo3/sysext/frontend/Tests/Unit/AdminPanelTest.php
deleted file mode 100644 (file)
index cfebb66..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-<?php
-namespace TYPO3\CMS\Frontend\Tests\Unit;
-
-/***************************************************************
- *  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 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('TYPO3\\CMS\\Frontend\\View\\AdminPanelView', array('dummy'), array(), '', FALSE);
-               $adminPanelMock->display();
-       }
-
-       /**
-        * @test
-        */
-       public function extendAdminPanelHookCallsExtendAdminPanelMethodOfHook() {
-               $hookClass = uniqid('tx_coretest');
-               $hookMock = $this->getMock('TYPO3\\CMS\\Frontend\\View\\AdminPanelViewHookInterface', 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('TYPO3\\CMS\\Frontend\\View\\AdminPanelView', array('dummy'), array(), '', FALSE);
-               $hookMock->expects($this->once())->method('extendAdminPanel')->with($this->isType('string'), $this->isInstanceOf('TYPO3\\CMS\\Frontend\\View\\AdminPanelView'));
-               $adminPanelMock->display();
-       }
-
-}
-
-
-?>
\ No newline at end of file
diff --git a/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php b/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php
new file mode 100644 (file)
index 0000000..54afdd9
--- /dev/null
@@ -0,0 +1,1034 @@
+<?php
+namespace TYPO3\CMS\Frontend\Tests\Unit\ContentObject;
+
+/***************************************************************
+ *  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 TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
+ *
+ * @package TYPO3
+ * @subpackage tslib
+ * @author Oliver Hader <oliver@typo3.org>
+ * @author Oliver Klee <typo3-coding@oliverklee.de>
+ */
+class ContentObjectRendererTest 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');
+
+       /**
+        * @var \PHPUnit_Framework_MockObject_MockObject|\Tx_Phpunit_Interface_AccessibleObject|\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
+        */
+       private $cObj;
+
+       /**
+        * @var \PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
+        */
+       private $tsfe;
+
+       /**
+        * @var \PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\TypoScript\TemplateService
+        */
+       private $template;
+
+       /**
+        * @var array
+        */
+       private $typoScriptImage = array('file' => 'typo3/clear.gif');
+
+       public function setUp() {
+               $this->template = $this->getMock('TYPO3\\CMS\\Core\\TypoScript\\TemplateService', array('getFileName', 'linkData'));
+               $this->tsfe = $this->getMock('TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', array(), array(), '', FALSE);
+               $this->tsfe->tmpl = $this->template;
+               $this->tsfe->config = array();
+               $sysPageMock = $this->getMock('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
+               $this->tsfe->sys_page = $sysPageMock;
+               $GLOBALS['TSFE'] = $this->tsfe;
+               $GLOBALS['TSFE']->csConvObj = new \TYPO3\CMS\Core\Charset\CharsetConverter();
+               $GLOBALS['TSFE']->renderCharset = 'utf-8';
+               $GLOBALS['TYPO3_CONF_VARS']['SYS']['TYPO3\\CMS\\Core\\Charset\\CharsetConverter_utils'] = 'mbstring';
+               $this->cObj = $this->getAccessibleMock('\\TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer', array('dummy'));
+               $this->cObj->start(array(), 'tt_content');
+       }
+
+       ////////////////////////
+       // 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('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectGetImageResourceHookInterface', array('getImgResourcePostProcess'), array(), $className);
+               $getImgResourceHookMock->expects($this->once())->method('getImgResourcePostProcess')->will($this->returnCallback(array($this, 'isGetImgResourceHookCalledCallback')));
+               $getImgResourceHookObjects = array($getImgResourceHookMock);
+               $this->cObj->_setRef('getImgResourceHookObjects', $getImgResourceHookObjects);
+               $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 \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer);
+               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:
+        * @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
+                               ),
+                               $charset . ' text with dash in html-element 28|...|1' => array(
+                                       '28|...|1',
+                                       'Some text with a link to <link email.address@example.org - mail "Open email window">my email.address@example.org</link> and text after it',
+                                       'Some text with a link to <link email.address@example.org - mail "Open email window">my...</link>',
+                                       $charset
+                               )
+                       ));
+               }
+               return $data;
+       }
+
+       /**
+        * Checks if stdWrap.cropHTML works with plain text cropping from left
+        *
+        * @test
+        * @dataProvider cropHtmlDataProvider
+        * @param string $settings
+        * @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:
+        * @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:
+        * @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:
+        * @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);
+       }
+
+       /**
+        * Data provider for the getQuery test
+        *
+        * @return array multi-dimensional array with the second level like this:
+        * @see getQuery
+        */
+       public function getQueryDataProvider() {
+               $data = array(
+                       'testing empty conf' => array(
+                               'tt_content',
+                               array(),
+                               array(
+                                       'SELECT' => '*'
+                               )
+                       ),
+                       'testing #17284: adding uid/pid for workspaces' => array(
+                               'tt_content',
+                               array(
+                                       'selectFields' => 'header,bodytext'
+                               ),
+                               array(
+                                       'SELECT' => 'header,bodytext, tt_content.uid as uid, tt_content.pid as pid, tt_content.t3ver_state as t3ver_state'
+                               )
+                       ),
+                       'testing #17284: no need to add' => array(
+                               'tt_content',
+                               array(
+                                       'selectFields' => 'tt_content.*'
+                               ),
+                               array(
+                                       'SELECT' => 'tt_content.*'
+                               )
+                       ),
+                       'testing #17284: no need to add #2' => array(
+                               'tt_content',
+                               array(
+                                       'selectFields' => '*'
+                               ),
+                               array(
+                                       'SELECT' => '*'
+                               )
+                       ),
+                       'testing #29783: joined tables, prefix tablename' => array(
+                               'tt_content',
+                               array(
+                                       'selectFields' => 'tt_content.header,be_users.username',
+                                       'join' => 'be_users ON tt_content.cruser_id = be_users.uid'
+                               ),
+                               array(
+                                       'SELECT' => 'tt_content.header,be_users.username, tt_content.uid as uid, tt_content.pid as pid, tt_content.t3ver_state as t3ver_state'
+                               )
+                       ),
+                       'testing #34152: single count(*), add nothing' => array(
+                               'tt_content',
+                               array(
+                                       'selectFields' => 'count(*)'
+                               ),
+                               array(
+                                       'SELECT' => 'count(*)'
+                               )
+                       ),
+                       'testing #34152: single max(crdate), add nothing' => array(
+                               'tt_content',
+                               array(
+                                       'selectFields' => 'max(crdate)'
+                               ),
+                               array(
+                                       'SELECT' => 'max(crdate)'
+                               )
+                       ),
+                       'testing #34152: single min(crdate), add nothing' => array(
+                               'tt_content',
+                               array(
+                                       'selectFields' => 'min(crdate)'
+                               ),
+                               array(
+                                       'SELECT' => 'min(crdate)'
+                               )
+                       ),
+                       'testing #34152: single sum(is_siteroot), add nothing' => array(
+                               'tt_content',
+                               array(
+                                       'selectFields' => 'sum(is_siteroot)'
+                               ),
+                               array(
+                                       'SELECT' => 'sum(is_siteroot)'
+                               )
+                       ),
+                       'testing #34152: single avg(crdate), add nothing' => array(
+                               'tt_content',
+                               array(
+                                       'selectFields' => 'avg(crdate)'
+                               ),
+                               array(
+                                       'SELECT' => 'avg(crdate)'
+                               )
+                       )
+               );
+               return $data;
+       }
+
+       /**
+        * Check if sanitizeSelectPart works as expected
+        *
+        * @dataProvider getQueryDataProvider
+        * @test
+        */
+       public function getQuery($table, $conf, $expected) {
+               $result = $this->cObj->getQuery($table, $conf, TRUE);
+               foreach ($expected as $field => $value) {
+                       $this->assertEquals($value, $result[$field]);
+               }
+       }
+
+}
+
+?>
\ No newline at end of file
index 309df2e..22773cd 100644 (file)
@@ -24,7 +24,7 @@ namespace TYPO3\CMS\Frontend\Tests\Unit\ContentObject\Menu;
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
 /**
- * Testcase for the "tslib_menu" class in the TYPO3 Core.
+ * Testcase for TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject
  *
  * @package TYPO3
  * @subpackage tslib
@@ -33,30 +33,49 @@ namespace TYPO3\CMS\Frontend\Tests\Unit\ContentObject\Menu;
 class AbstractMenuContentObjectTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
 
        /**
-        * @var \TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject
+        * Enable backup of global and system variables
+        *
+        * @var boolean
         */
-       private $fixture = NULL;
+       protected $backupGlobals = TRUE;
 
        /**
+        * Exclude TYPO3_DB from backup/ restore of $GLOBALS
+        * because resource types cannot be handled during serializing
+        *
         * @var array
         */
-       private $backupGlobalVariables = array();
+       protected $backupGlobalsBlacklist = array('TYPO3_DB');
+
+       /**
+        * A backup of the global database
+        *
+        * @var \TYPO3\CMS\Core\Database\DatabaseConnection
+        */
+       protected $databaseBackup = NULL;
 
+       /**
+        * @var \TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject
+        */
+       protected $fixture = NULL;
+
+       /**
+        * Set up this testcase
+        */
        public function setUp() {
                $proxy = $this->buildAccessibleProxy('TYPO3\\CMS\\Frontend\\ContentObject\\Menu\\AbstractMenuContentObject');
                $this->fixture = new $proxy();
-               $backupGlobalVariables['TYPO3_DB'] = $GLOBALS['TYPO3_DB'];
+               $this->databaseBackup = $GLOBALS['TYPO3_DB'];
                $GLOBALS['TYPO3_DB'] = $this->getMock('t3lib_db');
-               $backupGlobalVariables['TSFE'] = $GLOBALS['TSFE'];
                $GLOBALS['TSFE'] = $this->getMock('TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController');
                $GLOBALS['TSFE']->cObj = new \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer();
        }
 
+       /**
+        * Tear down this testcase
+        */
        public function tearDown() {
-               foreach ($this->backupGlobalVariables as $key => $data) {
-                       $GLOBALS[$key] = $data;
-               }
-               unset($this->fixture);
+               $GLOBALS['TYPO3_DB'] = $this->databaseBackup;
        }
 
        ////////////////////////////////
diff --git a/typo3/sysext/frontend/Tests/Unit/ContentTest.php b/typo3/sysext/frontend/Tests/Unit/ContentTest.php
deleted file mode 100644 (file)
index 801fd7a..0000000
+++ /dev/null
@@ -1,1048 +0,0 @@
-<?php
-namespace TYPO3\CMS\Frontend\Tests\Unit;
-
-/***************************************************************
- *  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 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('TYPO3\\CMS\\Core\\TypoScript\\TemplateService', array('getFileName', 'linkData'));
-               $this->tsfe = $this->getMock('TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', array(), array(), '', FALSE);
-               $this->tsfe->tmpl = $this->template;
-               $this->tsfe->config = array();
-               $sysPageMock = $this->getMock('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
-               $this->tsfe->sys_page = $sysPageMock;
-               $GLOBALS['TSFE'] = $this->tsfe;
-               $GLOBALS['TSFE']->csConvObj = new \TYPO3\CMS\Core\Charset\CharsetConverter();
-               $GLOBALS['TSFE']->renderCharset = 'utf-8';
-               $GLOBALS['TYPO3_CONF_VARS']['SYS']['TYPO3\\CMS\\Core\\Charset\\CharsetConverter_utils'] = 'mbstring';
-               $className = 'TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer_' . uniqid('test');
-               eval(('
-                       class ' . $className) . ' extends TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer {
-                               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('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectGetImageResourceHookInterface', 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 \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer);
-               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:
-        * @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
-                               ),
-                               $charset . ' text with dash in html-element 28|...|1' => array(
-                                       '28|...|1',
-                                       'Some text with a link to <link email.address@example.org - mail "Open email window">my email.address@example.org</link> and text after it',
-                                       'Some text with a link to <link email.address@example.org - mail "Open email window">my...</link>',
-                                       $charset
-                               )
-                       ));
-               }
-               return $data;
-       }
-
-       /**
-        * Checks if stdWrap.cropHTML works with plain text cropping from left
-        *
-        * @test
-        * @dataProvider cropHtmlDataProvider
-        * @param string $settings
-        * @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:
-        * @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:
-        * @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:
-        * @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);
-       }
-
-       /**
-        * Data provider for the getQuery test
-        *
-        * @return array multi-dimensional array with the second level like this:
-        * @see getQuery
-        */
-       public function getQueryDataProvider() {
-               $data = array(
-                       'testing empty conf' => array(
-                               'tt_content',
-                               array(),
-                               array(
-                                       'SELECT' => '*'
-                               )
-                       ),
-                       'testing #17284: adding uid/pid for workspaces' => array(
-                               'tt_content',
-                               array(
-                                       'selectFields' => 'header,bodytext'
-                               ),
-                               array(
-                                       'SELECT' => 'header,bodytext, tt_content.uid as uid, tt_content.pid as pid, tt_content.t3ver_state as t3ver_state'
-                               )
-                       ),
-                       'testing #17284: no need to add' => array(
-                               'tt_content',
-                               array(
-                                       'selectFields' => 'tt_content.*'
-                               ),
-                               array(
-                                       'SELECT' => 'tt_content.*'
-                               )
-                       ),
-                       'testing #17284: no need to add #2' => array(
-                               'tt_content',
-                               array(
-                                       'selectFields' => '*'
-                               ),
-                               array(
-                                       'SELECT' => '*'
-                               )
-                       ),
-                       'testing #29783: joined tables, prefix tablename' => array(
-                               'tt_content',
-                               array(
-                                       'selectFields' => 'tt_content.header,be_users.username',
-                                       'join' => 'be_users ON tt_content.cruser_id = be_users.uid'
-                               ),
-                               array(
-                                       'SELECT' => 'tt_content.header,be_users.username, tt_content.uid as uid, tt_content.pid as pid, tt_content.t3ver_state as t3ver_state'
-                               )
-                       ),
-                       'testing #34152: single count(*), add nothing' => array(
-                               'tt_content',
-                               array(
-                                       'selectFields' => 'count(*)'
-                               ),
-                               array(
-                                       'SELECT' => 'count(*)'
-                               )
-                       ),
-                       'testing #34152: single max(crdate), add nothing' => array(
-                               'tt_content',
-                               array(
-                                       'selectFields' => 'max(crdate)'
-                               ),
-                               array(
-                                       'SELECT' => 'max(crdate)'
-                               )
-                       ),
-                       'testing #34152: single min(crdate), add nothing' => array(
-                               'tt_content',
-                               array(
-                                       'selectFields' => 'min(crdate)'
-                               ),
-                               array(
-                                       'SELECT' => 'min(crdate)'
-                               )
-                       ),
-                       'testing #34152: single sum(is_siteroot), add nothing' => array(
-                               'tt_content',
-                               array(
-                                       'selectFields' => 'sum(is_siteroot)'
-                               ),
-                               array(
-                                       'SELECT' => 'sum(is_siteroot)'
-                               )
-                       ),
-                       'testing #34152: single avg(crdate), add nothing' => array(
-                               'tt_content',
-                               array(
-                                       'selectFields' => 'avg(crdate)'
-                               ),
-                               array(
-                                       'SELECT' => 'avg(crdate)'
-                               )
-                       )
-               );
-               return $data;
-       }
-
-       /**
-        * Check if sanitizeSelectPart works as expected
-        *
-        * @dataProvider getQueryDataProvider
-        * @test
-        */
-       public function getQuery($table, $conf, $expected) {
-               $result = $this->cObj->getQuery($table, $conf, TRUE);
-               foreach ($expected as $field => $value) {
-                       $this->assertEquals($value, $result[$field]);
-               }
-       }
-
-}
-
-
-?>
\ No newline at end of file
diff --git a/typo3/sysext/frontend/Tests/Unit/Controller/Fixtures/renderedPage.html b/typo3/sysext/frontend/Tests/Unit/Controller/Fixtures/renderedPage.html
new file mode 100644 (file)
index 0000000..cab1e65
--- /dev/null
@@ -0,0 +1,38 @@
+<!DOCTYPE html
+       PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<!-- 
+       This website is powered by TYPO3 - inspiring people to share!
+       TYPO3 is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.
+       TYPO3 is copyright 1998-2012 of Kasper Skaarhoj. Extensions are copyright of their respective owners.
+       Information and contribution at http://typo3.org/
+-->
+
+
+
+<title>powermail</title>
+<meta name="generator" content="TYPO3 6.0 CMS">
+
+<link rel="stylesheet" type="text/css" href="typo3temp/stylesheet_427bb03fe1.css?1334416344" media="all">
+
+
+
+<script src="typo3temp/javascript_175aa1ef20.js?1340313498" type="text/javascript"></script>
+
+
+<!--HD_679b52796e75d474ccbbed486b6837ab-->
+</head>
+<body>
+<!--TDS_679b52796e75d474ccbbed486b6837ab-->
+
+       <!--  CONTENT ELEMENT, uid:65/login [begin] -->
+               <div id="c65" class="csc-default csc-space-before- csc-space-after-"><!--INT_SCRIPT.13e1737dd0938292520612f3088602ba--></div>
+       <!--  CONTENT ELEMENT, uid:65/login [end] -->
+
+
+<!--FD_679b52796e75d474ccbbed486b6837ab-->
+</body>
+</html>
\ No newline at end of file
diff --git a/typo3/sysext/frontend/Tests/Unit/Controller/TypoScriptFrontentControllerTest.php b/typo3/sysext/frontend/Tests/Unit/Controller/TypoScriptFrontentControllerTest.php
new file mode 100644 (file)
index 0000000..32b0ca4
--- /dev/null
@@ -0,0 +1,167 @@
+<?php
+namespace TYPO3\CMS\Frontend\Tests\Unit\Controller;
+
+/***************************************************************
+ * 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 TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
+ *
+ * @package TYPO3
+ * @subpackage tslib
+ * @author Oliver Klee <typo3-coding@oliverklee.de>
+ */
+class TypoScriptFrontendControllerTest 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');
+
+       /**
+        * @var \PHPUnit_Framework_MockObject_MockObject|\Tx_Phpunit_Interface_AccessibleObject|\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
+        */
+       private $fixture;
+
+       public function setUp() {
+               $this->fixture = $this->getAccessibleMock('\\TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', array('dummy'), array(), '', FALSE);
+               $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 rendering content
+       ////////////////////////////////
+       /**
+        * @test
+        */
+       public function headerAndFooterMarkersAreReplacedDuringIntProcessing() {
+               $GLOBALS['TSFE'] = $this->setupTsfeMockForHeaderFooterReplacementCheck();
+               $GLOBALS['TSFE']->INTincScript();
+               $this->assertContains('headerData', $GLOBALS['TSFE']->content);
+               $this->assertContains('footerData', $GLOBALS['TSFE']->content);
+       }
+
+       /**
+        * This is the callback that mimics a USER_INT extension
+        */
+       public function INTincScript_processCallback() {
+               $GLOBALS['TSFE']->additionalHeaderData[] = 'headerData';
+               $GLOBALS['TSFE']->additionalFooterData[] = 'footerData';
+       }
+
+       /**
+        * Setup a tslib_fe object only for testing the header and footer
+        * replacement during USER_INT rendering
+        *
+        * @return \PHPUnit_Framework_MockObject_MockObject
+        */
+       protected function setupTsfeMockForHeaderFooterReplacementCheck() {
+               /** @var \PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $tsfe */
+               $tsfe = $this->getMock('TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', array(
+                       'INTincScript_process',
+                       'INTincScript_includeLibs',
+                       'INTincScript_loadJSCode',
+                       'setAbsRefPrefix'
+               ), array(), '', FALSE);
+               $tsfe->expects($this->once())->method('INTincScript_process')->will($this->returnCallback(array($this, 'INTincScript_processCallback')));
+               $tsfe->content = file_get_contents(__DIR__ . '/Fixtures/renderedPage.html');
+               $tsfe->config['INTincScript_ext']['divKey'] = '679b52796e75d474ccbbed486b6837ab';
+               $tsfe->config['INTincScript'] = array('INT_SCRIPT.679b52796e75d474ccbbed486b6837ab' => array());
+               $GLOBALS['TT'] = new \TYPO3\CMS\Core\TimeTracker\NullTimeTracker();
+               return $tsfe;
+       }
+
+       ////////////////////////////////
+       // 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->_callRef('roundTripCryptString', $clearText)));
+       }
+
+       /**
+        * @test
+        */
+       public function roundTripCryptStringCreatesResultDifferentFromInputString() {
+               $clearText = 'Hello world!';
+               $this->assertNotEquals($clearText, $this->fixture->_callRef('roundTripCryptString', $clearText));
+       }
+
+       /**
+        * @test
+        */
+       public function roundTripCryptStringAppliedTwoTimesReturnsOriginalString() {
+               $clearText = 'Hello world!';
+               $refValue = $this->fixture->_callRef('roundTripCryptString', $clearText);
+               $this->assertEquals($clearText, $this->fixture->_callRef('roundTripCryptString', $refValue));
+       }
+
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/frontend/Tests/Unit/FrontendTest.php b/typo3/sysext/frontend/Tests/Unit/FrontendTest.php
deleted file mode 100644 (file)
index 882fca7..0000000
+++ /dev/null
@@ -1,170 +0,0 @@
-<?php
-namespace TYPO3\CMS\Frontend\Tests\Unit;
-
-/***************************************************************
- * 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 FrontendTest 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');
-
-       /**
-        * @var \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
-        */
-       private $fixture;
-
-       public function setUp() {
-               // This creates an instance of the class without calling the
-               // original constructor.
-               $className = uniqid('TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController');
-               eval((((((((('class ' . $className) . ' extends TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController {') . 'public function ') . $className) . '() {}') . 'public function roundTripCryptString($string) {') . 'return parent::roundTripCryptString($string);') . '}') . '}');
-               $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 rendering content
-       ////////////////////////////////
-       /**
-        * @test
-        */
-       public function headerAndFooterMarkersAreReplacedDuringIntProcessing() {
-               $GLOBALS['TSFE'] = $this->setupTsfeMockForHeaderFooterReplacementCheck();
-               $GLOBALS['TSFE']->INTincScript();
-               $this->assertContains('headerData', $GLOBALS['TSFE']->content);
-               $this->assertContains('footerData', $GLOBALS['TSFE']->content);
-       }
-
-       /**
-        * This is the callback that mimics a USER_INT extension
-        */
-       public function INTincScript_processCallback() {
-               $GLOBALS['TSFE']->additionalHeaderData[] = 'headerData';
-               $GLOBALS['TSFE']->additionalFooterData[] = 'footerData';
-       }
-
-       /**
-        * Setup a tslib_fe object only for testing the header and footer
-        * replacement during USER_INT rendering
-        *
-        * @return PHPUnit_Framework_MockObject_MockObject
-        */
-       protected function setupTsfeMockForHeaderFooterReplacementCheck() {
-               $tsfe = $this->getMock('TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', array(
-                       'INTincScript_process',
-                       'INTincScript_includeLibs',
-                       'INTincScript_loadJSCode',
-                       'setAbsRefPrefix'
-               ), array(), '', FALSE);
-               $tsfe->expects($this->once())->method('INTincScript_process')->will($this->returnCallback(array($this, 'INTincScript_processCallback')));
-               $tsfe->content = file_get_contents(__DIR__ . '/../fixtures/renderedPage.html');
-               $tsfe->config['INTincScript_ext']['divKey'] = '679b52796e75d474ccbbed486b6837ab';
-               $tsfe->config['INTincScript'] = array('INT_SCRIPT.679b52796e75d474ccbbed486b6837ab' => array());
-               $GLOBALS['TT'] = new \t3lib_timeTrackNull();
-               return $tsfe;
-       }
-
-       ////////////////////////////////
-       // 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)));
-       }
-
-}
-
-
-?>
\ No newline at end of file
diff --git a/typo3/sysext/frontend/Tests/Unit/View/AdminPanelViewTest.php b/typo3/sysext/frontend/Tests/Unit/View/AdminPanelViewTest.php
new file mode 100644 (file)
index 0000000..3c4cf9d
--- /dev/null
@@ -0,0 +1,83 @@
+<?php
+namespace TYPO3\CMS\Frontend\Tests\Unit\View;
+
+/***************************************************************
+ *  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 TYPO3\CMS\Frontend\View\AdminPanelView
+ *
+ * @package TYPO3
+ * @subpackage tslib
+ * @author Christian Kuhn <lolli@schwarzbu.ch>
+ */
+class AdminPanelViewTest 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;
+               /** @var $adminPanelMock \PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Frontend\View\AdminPanelView */
+               $adminPanelMock = $this->getMock('TYPO3\\CMS\\Frontend\\View\\AdminPanelView', array('dummy'), array(), '', FALSE);
+               $adminPanelMock->display();
+       }
+
+       /**
+        * @test
+        */
+       public function extendAdminPanelHookCallsExtendAdminPanelMethodOfHook() {
+               $hookClass = uniqid('tx_coretest');
+               $hookMock = $this->getMock('TYPO3\\CMS\\Frontend\\View\\AdminPanelViewHookInterface', array(), array(), $hookClass);
+               $GLOBALS['T3_VAR']['getUserObj'][$hookClass] = $hookMock;
+               $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_adminpanel.php']['extendAdminPanel'][] = $hookClass;
+               /** @var $adminPanelMock \PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Frontend\View\AdminPanelView */
+               $adminPanelMock = $this->getMock('TYPO3\\CMS\\Frontend\\View\\AdminPanelView', array('dummy'), array(), '', FALSE);
+               $hookMock->expects($this->once())->method('extendAdminPanel')->with($this->isType('string'), $this->isInstanceOf('TYPO3\\CMS\\Frontend\\View\\AdminPanelView'));
+               $adminPanelMock->display();
+       }
+
+}
+
+?>
\ No newline at end of file