[TASK] Add tests for ContentObjectRenderer::getData() 73/22473/3
authorStefan Neufeind <typo3.neufeind@speedpartner.de>
Sun, 21 Jul 2013 19:42:13 +0000 (21:42 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 27 Jul 2013 19:20:30 +0000 (21:20 +0200)
* Adds unittests
* Cleanup and fix some things along the way
* Some modes didn't allow to be executed without
  adding a dummy-value (e.g. "parameters")

Change-Id: I2b4ff89c828384c852e6fbf9f82c55e6ebbac281
Resolves: #50258
Releases: 6.2
Reviewed-on: https://review.typo3.org/22473
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php

index 26aeea8..3efe744 100644 (file)
@@ -840,7 +840,7 @@ class ContentObjectRenderer {
         * @todo Define visibility
         */
        public function HTML($conf) {
-               \TYPO3\CMS\Core\Utility\GeneralUtility::logDeprecatedFunction();
+               GeneralUtility::logDeprecatedFunction();
                return '';
        }
 
@@ -1139,7 +1139,7 @@ class ContentObjectRenderer {
         * @todo Define visibility
         */
        public function PHP_SCRIPT($conf, $ext = '') {
-               \TYPO3\CMS\Core\Utility\GeneralUtility::logDeprecatedFunction();
+               GeneralUtility::logDeprecatedFunction();
                return '';
        }
 
@@ -1328,8 +1328,8 @@ class ContentObjectRenderer {
                $info = $this->getImgResource($file, $conf['file.']);
                $GLOBALS['TSFE']->lastImageInfo = $info;
                if (is_array($info)) {
-                       if (\TYPO3\CMS\Core\Utility\GeneralUtility::isAllowedAbsPath(PATH_site . $info['3'])) {
-                               $source = GeneralUtility::rawUrlEncodeFP(\TYPO3\CMS\Core\Utility\GeneralUtility::png_to_gif_by_imagemagick($info[3]));
+                       if (GeneralUtility::isAllowedAbsPath(PATH_site . $info['3'])) {
+                               $source = GeneralUtility::rawUrlEncodeFP(GeneralUtility::png_to_gif_by_imagemagick($info[3]));
                                $source = $GLOBALS['TSFE']->absRefPrefix . $source;
                        } else {
                                $source = $info[3];
@@ -1366,7 +1366,7 @@ class ContentObjectRenderer {
         * @todo Define visibility
         */
        public function getBorderAttr($borderAttr) {
-               if (!\TYPO3\CMS\Core\Utility\GeneralUtility::inList('xhtml_strict,xhtml_11,xhtml_2', $GLOBALS['TSFE']->xhtmlDoctype) && $GLOBALS['TSFE']->config['config']['doctype'] != 'html5' && !$GLOBALS['TSFE']->config['config']['disableImgBorderAttr']) {
+               if (!GeneralUtility::inList('xhtml_strict,xhtml_11,xhtml_2', $GLOBALS['TSFE']->xhtmlDoctype) && $GLOBALS['TSFE']->config['config']['doctype'] != 'html5' && !$GLOBALS['TSFE']->config['config']['disableImgBorderAttr']) {
                        return $borderAttr;
                }
        }
@@ -1427,7 +1427,7 @@ class ContentObjectRenderer {
                                        }
                                }
                                // Create TARGET-attribute only if the right doctype is used
-                               if (!\TYPO3\CMS\Core\Utility\GeneralUtility::inList('xhtml_strict,xhtml_11,xhtml_2', $GLOBALS['TSFE']->xhtmlDoctype)) {
+                               if (!GeneralUtility::inList('xhtml_strict,xhtml_11,xhtml_2', $GLOBALS['TSFE']->xhtmlDoctype)) {
                                        $target = isset($conf['target.']) ? $this->stdWrap($conf['target'], $conf['target.']) : $conf['target'];
                                        if ($target) {
                                                $target = sprintf(' target="%s"', $target);
@@ -1481,7 +1481,7 @@ class ContentObjectRenderer {
                $incFile = $GLOBALS['TSFE']->tmpl->getFileName($fName);
                if ($incFile) {
                        $fileinfo = GeneralUtility::split_fileref($incFile);
-                       if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList('jpg,gif,jpeg,png', $fileinfo['fileext'])) {
+                       if (GeneralUtility::inList('jpg,gif,jpeg,png', $fileinfo['fileext'])) {
                                $imgFile = $incFile;
                                $imgInfo = @getImageSize($imgFile);
                                return '<img src="' . $GLOBALS['TSFE']->absRefPrefix . $imgFile . '" width="' . $imgInfo[0] . '" height="' . $imgInfo[1] . '"' . $this->getBorderAttr(' border="0"') . ' ' . $addParams . ' />';
@@ -1992,7 +1992,7 @@ class ContentObjectRenderer {
                                        // if yes, execute them first - will make each function stdWrap aware
                                        // so additional stdWrap calls within the functions can be removed, since the result will be the same
                                        // exception: the recursive stdWrap function and cObject will still be using their own stdWrap call, since it modifies the content and not a property
-                                       if (count($conf[$functionProperties]) && !\TYPO3\CMS\Core\Utility\GeneralUtility::inList($stdWrapDisabledFunctionTypes, $functionType)) {
+                                       if (count($conf[$functionProperties]) && !GeneralUtility::inList($stdWrapDisabledFunctionTypes, $functionType)) {
                                                if (array_intersect_key($this->stdWrapOrder, $conf[$functionProperties])) {
                                                        $conf[$functionName] = $this->stdWrap($conf[$functionName], $conf[$functionProperties]);
                                                }
@@ -3376,7 +3376,7 @@ class ContentObjectRenderer {
                                                        'lifetime' => $lifetime,
                                                        'tags' => $tags
                                                );
-                                               \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($_funcRef, $params, $this);
+                                               GeneralUtility::callUserFunction($_funcRef, $params, $this);
                                        }
                                }
                                $cacheFrontend->set($conf['cache.']['key'], $content, $tags, $lifetime);
@@ -3556,7 +3556,7 @@ class ContentObjectRenderer {
                        }
                        if (isset($conf['isInList']) || isset($conf['isInList.'])) {
                                $number = isset($conf['isInList.']) ? trim($this->stdWrap($conf['isInList'], $conf['isInList.'])) : trim($conf['isInList']);
-                               if (!\TYPO3\CMS\Core\Utility\GeneralUtility::inList($value, $number)) {
+                               if (!GeneralUtility::inList($value, $number)) {
                                        $flag = 0;
                                }
                        }
@@ -3594,7 +3594,7 @@ class ContentObjectRenderer {
                                        'files' => array(),
                                        'sorting' => array()
                                );
-                               $ext_list = strtolower(\TYPO3\CMS\Core\Utility\GeneralUtility::uniqueList($data_arr[1]));
+                               $ext_list = strtolower(GeneralUtility::uniqueList($data_arr[1]));
                                $sorting = trim($data_arr[2]);
                                // Read dir:
                                $d = @dir($path);
@@ -3668,10 +3668,10 @@ class ContentObjectRenderer {
         */
        public function clean_directory($theDir) {
                // proceeds if no '//', '..' or '\' is in the $theFile
-               if (\TYPO3\CMS\Core\Utility\GeneralUtility::validPathStr($theDir)) {
+               if (GeneralUtility::validPathStr($theDir)) {
                        // Removes all dots, slashes and spaces after a path...
                        $theDir = preg_replace('/[\\/\\. ]*$/', '', $theDir);
-                       if (!\TYPO3\CMS\Core\Utility\GeneralUtility::isAbsPath($theDir) && @is_dir($theDir)) {
+                       if (!GeneralUtility::isAbsPath($theDir) && @is_dir($theDir)) {
                                return $theDir;
                        }
                }
@@ -4849,7 +4849,7 @@ class ContentObjectRenderer {
                                } else {
                                        // If a tag was not a typo tag, then it is just added to the content
                                        $stripNL = 0;
-                                       if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList($allowTags, $tag[0]) || $denyTags != '*' && !\TYPO3\CMS\Core\Utility\GeneralUtility::inList($denyTags, $tag[0])) {
+                                       if (GeneralUtility::inList($allowTags, $tag[0]) || $denyTags != '*' && !GeneralUtility::inList($denyTags, $tag[0])) {
                                                $contentAccum[$contentAccumP] .= $data;
                                        } else {
                                                $contentAccum[$contentAccumP] .= HTMLSpecialChars($data);
@@ -5172,7 +5172,7 @@ class ContentObjectRenderer {
                                                $processingConfiguration['stripProfile'] = $fileArray['stripProfile'];
                                        }
                                        // Check if we can handle this type of file for editing
-                                       if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $fileObject->getExtension())) {
+                                       if (GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $fileObject->getExtension())) {
                                                $maskArray = $fileArray['m.'];
                                                // Must render mask images and include in hash-calculating
                                                // - otherwise we cannot be sure the filename is unique for the setup!
@@ -5261,13 +5261,12 @@ class ContentObjectRenderer {
         * Implements the TypoScript data type "getText". This takes a string with parameters and based on those a value from somewhere in the system is returned.
         *
         * @param string $string The parameter string, eg. "field : title" or "field : navtitle // field : title" (in the latter case and example of how the value is FIRST splitted by "//" is shown)
-        * @param mixed $fieldArray Alternative field array; If you set this to an array this variable will be used to look up values for the "field" key. Otherwise the current page record in $GLOBALS['TSFE']->page is used.
+        * @param NULL|array $fieldArray Alternative field array; If you set this to an array this variable will be used to look up values for the "field" key. Otherwise the current page record in $GLOBALS['TSFE']->page is used.
         * @return string The value fetched
         * @see getFieldVal()
         * @todo Define visibility
         */
-       public function getData($string, $fieldArray) {
-               global $TYPO3_CONF_VARS;
+       public function getData($string, $fieldArray = NULL) {
                if (!is_array($fieldArray)) {
                        $fieldArray = $GLOBALS['TSFE']->page;
                }
@@ -5275,13 +5274,14 @@ class ContentObjectRenderer {
                $sections = explode('//', $string);
                while (!$retVal and list($secKey, $secVal) = each($sections)) {
                        $parts = explode(':', $secVal, 2);
+                       $type = strtolower(trim($parts[0]));
+                       $typesWithOutParameters = array('level', 'date', 'current');
                        $key = trim($parts[1]);
-                       if ((string) $key != '') {
-                               $type = strtolower(trim($parts[0]));
+                       if (($key != '') || in_array($type, $typesWithOutParameters)) {
                                switch ($type) {
                                        case 'gp':
                                                // Merge GET and POST and get $key out of the merged array
-                                               $retVal = $this->getGlobal($key, GeneralUtility::array_merge_recursive_overrule(\TYPO3\CMS\Core\Utility\GeneralUtility::_GET(), GeneralUtility::_POST()));
+                                               $retVal = $this->getGlobal($key, GeneralUtility::array_merge_recursive_overrule(GeneralUtility::_GET(), GeneralUtility::_POST()));
                                                break;
                                        case 'tsfe':
                                                $retVal = $this->getGlobal('TSFE|' . $key);
@@ -5307,28 +5307,33 @@ class ContentObjectRenderer {
                                        case 'global':
                                                $retVal = $this->getGlobal($key);
                                                break;
+                                       case 'level':
+                                               $retVal = count($GLOBALS['TSFE']->tmpl->rootLine) - 1;
+                                               break;
                                        case 'leveltitle':
-                                               $nkey = $this->getKey($key, $GLOBALS['TSFE']->tmpl->rootLine);
-                                               $retVal = $this->rootLineValue($nkey, 'title', stristr($key, 'slide'));
+                                               $keyParts = GeneralUtility::trimExplode(',', $key);
+                                               $numericKey = $this->getKey($keyParts[0], $GLOBALS['TSFE']->tmpl->rootLine);
+                                               $retVal = $this->rootLineValue($numericKey, 'title', strtolower($keyParts[1]) === 'slide');
                                                break;
                                        case 'levelmedia':
-                                               $nkey = $this->getKey($key, $GLOBALS['TSFE']->tmpl->rootLine);
-                                               $retVal = $this->rootLineValue($nkey, 'media', stristr($key, 'slide'));
+                                               $keyParts = GeneralUtility::trimExplode(',', $key);
+                                               $numericKey = $this->getKey($keyParts[0], $GLOBALS['TSFE']->tmpl->rootLine);
+                                               $retVal = $this->rootLineValue($numericKey, 'media', strtolower($keyParts[1]) === 'slide');
                                                break;
                                        case 'leveluid':
-                                               $nkey = $this->getKey($key, $GLOBALS['TSFE']->tmpl->rootLine);
-                                               $retVal = $this->rootLineValue($nkey, 'uid', stristr($key, 'slide'));
+                                               $numericKey = $this->getKey($key, $GLOBALS['TSFE']->tmpl->rootLine);
+                                               $retVal = $this->rootLineValue($numericKey, 'uid');
                                                break;
                                        case 'levelfield':
-                                               $keyP = GeneralUtility::trimExplode(',', $key);
-                                               $nkey = $this->getKey($keyP[0], $GLOBALS['TSFE']->tmpl->rootLine);
-                                               $retVal = $this->rootLineValue($nkey, $keyP[1], strtolower($keyP[2]) == 'slide');
+                                               $keyParts = GeneralUtility::trimExplode(',', $key);
+                                               $numericKey = $this->getKey($keyParts[0], $GLOBALS['TSFE']->tmpl->rootLine);
+                                               $retVal = $this->rootLineValue($numericKey, $keyParts[1], strtolower($keyParts[2]) === 'slide');
                                                break;
                                        case 'fullrootline':
-                                               $keyP = GeneralUtility::trimExplode(',', $key);
-                                               $fullKey = intval($keyP[0]) - count($GLOBALS['TSFE']->tmpl->rootLine) + count($GLOBALS['TSFE']->rootLine);
+                                               $keyParts = GeneralUtility::trimExplode(',', $key);
+                                               $fullKey = intval($keyParts[0]) - count($GLOBALS['TSFE']->tmpl->rootLine) + count($GLOBALS['TSFE']->rootLine);
                                                if ($fullKey >= 0) {
-                                                       $retVal = $this->rootLineValue($fullKey, $keyP[1], stristr($keyP[2], 'slide'), $GLOBALS['TSFE']->rootLine);
+                                                       $retVal = $this->rootLineValue($fullKey, $keyParts[1], stristr($keyParts[2], 'slide'), $GLOBALS['TSFE']->rootLine);
                                                }
                                                break;
                                        case 'date':
@@ -5343,9 +5348,6 @@ class ContentObjectRenderer {
                                        case 'current':
                                                $retVal = $this->data[$this->currentValKey];
                                                break;
-                                       case 'level':
-                                               $retVal = count($GLOBALS['TSFE']->tmpl->rootLine) - 1;
-                                               break;
                                        case 'db':
                                                $selectParts = GeneralUtility::trimExplode(':', $key);
                                                $db_rec = $GLOBALS['TSFE']->sys_page->getRawRecord($selectParts[0], $selectParts[1]);
@@ -5360,14 +5362,14 @@ class ContentObjectRenderer {
                                                $retVal = $GLOBALS['TSFE']->tmpl->getFileName($key);
                                                break;
                                        case 'cobj':
-                                               switch ((string) $key) {
+                                               switch ($key) {
                                                        case 'parentRecordNumber':
                                                                $retVal = $this->parentRecordNumber;
                                                                break;
                                                }
                                                break;
                                        case 'debug':
-                                               switch ((string) $key) {
+                                               switch ($key) {
                                                        case 'rootLine':
                                                                $retVal = \TYPO3\CMS\Core\Utility\DebugUtility::viewArray($GLOBALS['TSFE']->tmpl->rootLine);
                                                                break;
@@ -5927,13 +5929,13 @@ class ContentObjectRenderer {
                                                                $absoluteUrlScheme = (int) $page['url_scheme'] === \TYPO3\CMS\Core\Utility\HttpUtility::SCHEME_HTTP ? 'http' : 'https';
                                                        }
                                                        // If no domain records are defined, use current domain:
-                                                       $currentUrlScheme = parse_url(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'), PHP_URL_SCHEME);
+                                                       $currentUrlScheme = parse_url(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'), PHP_URL_SCHEME);
                                                        if ($targetDomain === '' && ($conf['forceAbsoluteUrl'] || $absoluteUrlScheme !== $currentUrlScheme)) {
                                                                $targetDomain = $currentDomain;
                                                        }
                                                        // If go for an absolute link, add site path if it's not taken care about by absRefPrefix
                                                        if (!$GLOBALS['TSFE']->config['config']['absRefPrefix'] && $targetDomain == $currentDomain) {
-                                                               $targetDomain = $currentDomain . rtrim(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_PATH'), '/');
+                                                               $targetDomain = $currentDomain . rtrim(GeneralUtility::getIndpEnv('TYPO3_SITE_PATH'), '/');
                                                        }
                                                }
                                                // If target page has a different domain and the current domain's linking scheme (e.g. RealURL/...) should not be used
@@ -6023,7 +6025,7 @@ class ContentObjectRenderer {
                        }
                        if ($JSwindowParams) {
                                // Create TARGET-attribute only if the right doctype is used
-                               if (!\TYPO3\CMS\Core\Utility\GeneralUtility::inList('xhtml_strict,xhtml_11,xhtml_2', $GLOBALS['TSFE']->xhtmlDoctype)) {
+                               if (!GeneralUtility::inList('xhtml_strict,xhtml_11,xhtml_2', $GLOBALS['TSFE']->xhtmlDoctype)) {
                                        $target = ' target="FEopenLink"';
                                } else {
                                        $target = '';
@@ -6051,7 +6053,7 @@ class ContentObjectRenderer {
                                        'finalTagParts' => &$finalTagParts
                                );
                                foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['typoLink_PostProc'] as $_funcRef) {
-                                       \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($_funcRef, $_params, $this);
+                                       GeneralUtility::callUserFunction($_funcRef, $_params, $this);
                                }
                        }
                        // If flag "returnLastTypoLinkUrl" set, then just return the latest URL made:
@@ -6316,13 +6318,13 @@ class ContentObjectRenderer {
                                $currentQueryArray = GeneralUtility::_POST();
                                break;
                        case 'GET,POST':
-                               $currentQueryArray = array_merge(\TYPO3\CMS\Core\Utility\GeneralUtility::_GET(), GeneralUtility::_POST());
+                               $currentQueryArray = array_merge(GeneralUtility::_GET(), GeneralUtility::_POST());
                                break;
                        case 'POST,GET':
-                               $currentQueryArray = array_merge(\TYPO3\CMS\Core\Utility\GeneralUtility::_POST(), GeneralUtility::_GET());
+                               $currentQueryArray = array_merge(GeneralUtility::_POST(), GeneralUtility::_GET());
                                break;
                        default:
-                               $currentQueryArray = GeneralUtility::explodeUrl2Array(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('QUERY_STRING'), TRUE);
+                               $currentQueryArray = GeneralUtility::explodeUrl2Array(GeneralUtility::getIndpEnv('QUERY_STRING'), TRUE);
                }
                if ($conf['exclude']) {
                        $exclude = str_replace(',', '&', $conf['exclude']);
@@ -6478,7 +6480,7 @@ class ContentObjectRenderer {
                $lines = GeneralUtility::trimExplode(LF, $params, TRUE);
                foreach ($lines as $val) {
                        $pair = explode('=', $val, 2);
-                       if (!\TYPO3\CMS\Core\Utility\GeneralUtility::inList('#,/', substr(trim($pair[0]), 0, 1))) {
+                       if (!GeneralUtility::inList('#,/', substr(trim($pair[0]), 0, 1))) {
                                $paramArr[trim($pair[0])] = trim($pair[1]);
                        }
                }
@@ -6966,7 +6968,7 @@ class ContentObjectRenderer {
                        $fieldList = implode(',', GeneralUtility::trimExplode(',', $fieldList, TRUE));
                        $updateFields = array();
                        foreach ($dataArr as $f => $v) {
-                               if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList($fieldList, $f)) {
+                               if (GeneralUtility::inList($fieldList, $f)) {
                                        $updateFields[$f] = $v;
                                }
                        }
@@ -7035,7 +7037,7 @@ class ContentObjectRenderer {
                $fieldList = implode(',', GeneralUtility::trimExplode(',', $fieldList . ',' . $extraList, TRUE));
                $insertFields = array();
                foreach ($dataArr as $f => $v) {
-                       if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList($fieldList, $f)) {
+                       if (GeneralUtility::inList($fieldList, $f)) {
                                $insertFields[$f] = $v;
                        }
                }
@@ -7059,7 +7061,7 @@ class ContentObjectRenderer {
         * @todo Define visibility
         */
        public function DBmayFEUserEdit($table, $row, $feUserRow, $allowedGroups = '', $feEditSelf = 0) {
-               $groupList = $allowedGroups ? implode(',', array_intersect(\TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $feUserRow['usergroup'], TRUE), GeneralUtility::trimExplode(',', $allowedGroups, TRUE))) : $feUserRow['usergroup'];
+               $groupList = $allowedGroups ? implode(',', array_intersect(GeneralUtility::trimExplode(',', $feUserRow['usergroup'], TRUE), GeneralUtility::trimExplode(',', $allowedGroups, TRUE))) : $feUserRow['usergroup'];
                $ok = 0;
                // Points to the field that allows further editing from frontend if not set. If set the record is locked.
                if (!$GLOBALS['TCA'][$table]['ctrl']['fe_admin_lock'] || !$row[$GLOBALS['TCA'][$table]['ctrl']['fe_admin_lock']]) {
@@ -7078,7 +7080,7 @@ class ContentObjectRenderer {
                        if ($GLOBALS['TCA'][$table]['ctrl']['fe_crgroup_id']) {
                                $rowFEUser = intval($row[$GLOBALS['TCA'][$table]['ctrl']['fe_crgroup_id']]);
                                if ($rowFEUser) {
-                                       if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList($groupList, $rowFEUser)) {
+                                       if (GeneralUtility::inList($groupList, $rowFEUser)) {
                                                $ok = 1;
                                        }
                                }
@@ -7102,7 +7104,7 @@ class ContentObjectRenderer {
         */
        public function DBmayFEUserEditSelect($table, $feUserRow, $allowedGroups = '', $feEditSelf = 0) {
                // Returns where-definition that selects user-editable records.
-               $groupList = $allowedGroups ? implode(',', array_intersect(\TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $feUserRow['usergroup'], TRUE), GeneralUtility::trimExplode(',', $allowedGroups, TRUE))) : $feUserRow['usergroup'];
+               $groupList = $allowedGroups ? implode(',', array_intersect(GeneralUtility::trimExplode(',', $feUserRow['usergroup'], TRUE), GeneralUtility::trimExplode(',', $allowedGroups, TRUE))) : $feUserRow['usergroup'];
                $OR_arr = array();
                // Points to the field (integer) that holds the fe_users-id of the creator fe_user
                if ($GLOBALS['TCA'][$table]['ctrl']['fe_cruser_id']) {
index 4eccc2a..8fef6a5 100644 (file)
@@ -55,7 +55,7 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $this->tsfe->tmpl = $this->template;
                $this->tsfe->config = array();
                $this->tsfe->page = array();
-               $sysPageMock = $this->getMock('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
+               $sysPageMock = $this->getMock('TYPO3\\CMS\\Frontend\\Page\\PageRepository', array('getRawRecord'));
                $this->tsfe->sys_page = $sysPageMock;
                $GLOBALS['TSFE'] = $this->tsfe;
                $GLOBALS['TSFE']->csConvObj = new \TYPO3\CMS\Core\Charset\CharsetConverter();
@@ -1382,6 +1382,443 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                        ),
                );
        }
+
+
+       /////////////////////////////
+       // Tests concerning getData()
+       /////////////////////////////
+
+       /**
+        * @return array
+        */
+       public function getDataWithTypeGpDataProvider() {
+               return array(
+                       'Value in get-data' => array('onlyInGet', 'GetValue'),
+                       'Value in post-data' => array('onlyInPost', 'PostValue'),
+                       'Value in post-data overriding get-data' => array('inGetAndPost', 'ValueInPost'),
+               );
+       }
+
+       /**
+        * Checks if getData() works with type "gp"
+        *
+        * @test
+        * @dataProvider getDataWithTypeGpDataProvider
+        */
+       public function getDataWithTypeGp($key, $expectedValue) {
+               $_GET = array(
+                       'onlyInGet' => 'GetValue',
+                       'inGetAndPost' => 'ValueInGet',
+               );
+               $_POST = array(
+                       'onlyInPost' => 'PostValue',
+                       'inGetAndPost' => 'ValueInPost',
+               );
+               $this->assertEquals($expectedValue, $this->cObj->getData('gp:' . $key));
+       }
+
+       /**
+        * Checks if getData() works with type "tsfe"
+        *
+        * @test
+        */
+       public function getDataWithTypeTsfe() {
+               $this->assertEquals($GLOBALS['TSFE']->renderCharset, $this->cObj->getData('tsfe:renderCharset'));
+       }
+
+       /**
+        * Checks if getData() works with type "getenv"
+        *
+        * @test
+        */
+       public function getDataWithTypeGetenv() {
+               $envName = uniqid('frontendtest');
+               $value = uniqid('someValue');
+               putenv($envName . '=' . $value);
+               $this->assertEquals($value, $this->cObj->getData('getenv:' . $envName));
+       }
+
+       /**
+        * Checks if getData() works with type "getindpenv"
+        *
+        * @test
+        */
+       public function getDataWithTypeGetindpenv() {
+               $this->assertEquals(PATH_thisScript, $this->cObj->getData('getindpenv:SCRIPT_FILENAME'));
+       }
+
+       /**
+        * Checks if getData() works with type "getindpenv"
+        *
+        * @test
+        */
+       public function getDataWithTypeField() {
+               $key = 'someKey';
+               $value = 'someValue';
+               $field = array($key => $value);
+
+               $this->assertEquals($value, $this->cObj->getData('field:' . $key, $field));
+       }
+
+       /**
+        * Checks if getData() works with type "file"
+        *
+        * @test
+        */
+       public function getDataWithTypeFile() {
+               $uid = rand();
+               $properties = array(
+                       uniqid() => uniqid(),
+                       uniqid() => uniqid(),
+                       'uid' => $uid
+               );
+               $file = new \TYPO3\CMS\Core\Resource\File($properties);
+               $this->cObj->setCurrentFile($file);
+
+               $this->assertEquals($uid, $this->cObj->getData('file:current:uid'));
+       }
+
+       /**
+        * Checks if getData() works with type "parameters"
+        *
+        * @test
+        */
+       public function getDataWithTypeParameters() {
+               $key = uniqid('someKey');
+               $value = uniqid('someValue');
+               $this->cObj->parameters[$key] = $value;
+
+               $this->assertEquals($value, $this->cObj->getData('parameters:' . $key));
+       }
+
+       /**
+        * Checks if getData() works with type "register"
+        *
+        * @test
+        */
+       public function getDataWithTypeRegister() {
+               $key = uniqid('someKey');
+               $value = uniqid('someValue');
+               $GLOBALS['TSFE']->register[$key] = $value;
+
+               $this->assertEquals($value, $this->cObj->getData('register:' . $key));
+       }
+
+       /**
+        * Checks if getData() works with type "level"
+        *
+        * @test
+        */
+       public function getDataWithTypeLevel() {
+               $rootline = array(
+                       0 => array('uid' => 1, 'title' => 'title1'),
+                       1 => array('uid' => 2, 'title' => 'title2'),
+                       2 => array('uid' => 3, 'title' => 'title3'),
+               );
+
+               $GLOBALS['TSFE']->tmpl->rootLine = $rootline;
+               $this->assertEquals(2, $this->cObj->getData('level'));
+       }
+
+       /**
+        * Checks if getData() works with type "global"
+        *
+        * @test
+        */
+       public function getDataWithTypeGlobal() {
+               $this->assertEquals($GLOBALS['TSFE']->renderCharset, $this->cObj->getData('global:TSFE|renderCharset'));
+       }
+
+       /**
+        * Checks if getData() works with type "leveltitle"
+        *
+        * @test
+        */
+       public function getDataWithTypeLeveltitle() {
+               $rootline = array(
+                       0 => array('uid' => 1, 'title' => 'title1'),
+                       1 => array('uid' => 2, 'title' => 'title2'),
+                       2 => array('uid' => 3, 'title' => ''),
+               );
+
+               $GLOBALS['TSFE']->tmpl->rootLine = $rootline;
+               $this->assertEquals('', $this->cObj->getData('leveltitle:-1'));
+               // since "title3" is not set, it will slide to "title2"
+               $this->assertEquals('title2', $this->cObj->getData('leveltitle:-1,slide'));
+       }
+
+       /**
+        * Checks if getData() works with type "levelmedia"
+        *
+        * @test
+        */
+       public function getDataWithTypeLevelmedia() {
+               $rootline = array(
+                       0 => array('uid' => 1, 'title' => 'title1', 'media' => 'media1'),
+                       1 => array('uid' => 2, 'title' => 'title2', 'media' => 'media2'),
+                       2 => array('uid' => 3, 'title' => 'title3', 'media' => ''),
+               );
+
+               $GLOBALS['TSFE']->tmpl->rootLine = $rootline;
+               $this->assertEquals('', $this->cObj->getData('levelmedia:-1'));
+               // since "title3" is not set, it will slide to "title2"
+               $this->assertEquals('media2', $this->cObj->getData('levelmedia:-1,slide'));
+       }
+
+       /**
+        * Checks if getData() works with type "leveluid"
+        *
+        * @test
+        */
+       public function getDataWithTypeLeveluid() {
+               $rootline = array(
+                       0 => array('uid' => 1, 'title' => 'title1'),
+                       1 => array('uid' => 2, 'title' => 'title2'),
+                       2 => array('uid' => 3, 'title' => 'title3'),
+               );
+
+               $GLOBALS['TSFE']->tmpl->rootLine = $rootline;
+               $this->assertEquals(3, $this->cObj->getData('leveluid:-1'));
+               // every element will have a uid - so adding slide doesn't really make sense, just for completeness
+               $this->assertEquals(3, $this->cObj->getData('leveluid:-1,slide'));
+       }
+
+       /**
+        * Checks if getData() works with type "levelfield"
+        *
+        * @test
+        */
+       public function getDataWithTypeLevelfield() {
+               $rootline = array(
+                       0 => array('uid' => 1, 'title' => 'title1', 'testfield' => 'field1'),
+                       1 => array('uid' => 2, 'title' => 'title2', 'testfield' => 'field2'),
+                       2 => array('uid' => 3, 'title' => 'title3', 'testfield' => ''),
+               );
+
+               $GLOBALS['TSFE']->tmpl->rootLine = $rootline;
+               $this->assertEquals('', $this->cObj->getData('levelfield:-1,testfield'));
+               $this->assertEquals('field2', $this->cObj->getData('levelfield:-1,testfield,slide'));
+       }
+
+       /**
+        * Checks if getData() works with type "fullrootline"
+        *
+        * @test
+        */
+       public function getDataWithTypeFullrootline() {
+               $rootline1 = array(
+                       0 => array('uid' => 1, 'title' => 'title1', 'testfield' => 'field1'),
+               );
+               $rootline2 = array(
+                       0 => array('uid' => 1, 'title' => 'title1', 'testfield' => 'field1'),
+                       1 => array('uid' => 2, 'title' => 'title2', 'testfield' => 'field2'),
+                       2 => array('uid' => 3, 'title' => 'title3', 'testfield' => 'field3'),
+               );
+
+               $GLOBALS['TSFE']->tmpl->rootLine = $rootline1;
+               $GLOBALS['TSFE']->rootLine = $rootline2;
+               $this->assertEquals('field2', $this->cObj->getData('fullrootline:-1,testfield'));
+       }
+
+       /**
+        * Checks if getData() works with type "date"
+        *
+        * @test
+        */
+       public function getDataWithTypeDate() {
+               $format = 'Y-M-D';
+               $defaultFormat = 'd/m Y';
+
+               $this->assertEquals(date($format, $GLOBALS['EXEC_TIME']), $this->cObj->getData('date:' . $format));
+               $this->assertEquals(date($defaultFormat, $GLOBALS['EXEC_TIME']), $this->cObj->getData('date'));
+       }
+
+       /**
+        * Checks if getData() works with type "page"
+        *
+        * @test
+        */
+       public function getDataWithTypePage() {
+               $uid = rand();
+               $GLOBALS['TSFE']->page['uid'] = $uid;
+               $this->assertEquals($uid, $this->cObj->getData('page:uid'));
+       }
+
+       /**
+        * Checks if getData() works with type "current"
+        *
+        * @test
+        */
+       public function getDataWithTypeCurrent() {
+               $key = uniqid('someKey');
+               $value = uniqid('someValue');
+               $this->cObj->data[$key] = $value;
+               $this->cObj->currentValKey = $key;
+               $this->assertEquals($value, $this->cObj->getData('current'));
+       }
+
+       /**
+        * Checks if getData() works with type "db"
+        *
+        * @test
+        */
+       public function getDataWithTypeDb() {
+               $dummyRecord = array('uid' => 5, 'title' => 'someTitle');
+
+               $GLOBALS['TSFE']->sys_page->expects($this->atLeastOnce())->method('getRawRecord')->with('tt_content', '106')->will($this->returnValue($dummyRecord));
+               $this->assertEquals($dummyRecord['title'], $this->cObj->getData('db:tt_content:106:title'));
+       }
+
+       /**
+        * Checks if getData() works with type "lll"
+        *
+        * @test
+        */
+       public function getDataWithTypeLll() {
+               $key = uniqid('someKey');
+               $value = uniqid('someValue');
+               $language = uniqid('someLanguage');
+               $GLOBALS['TSFE']->LL_labels_cache[$language]['LLL:' . $key] = $value;
+               $GLOBALS['TSFE']->lang = $language;
+
+               $this->assertEquals($value, $this->cObj->getData('lll:' . $key));
+       }
+
+       /**
+        * Checks if getData() works with type "path"
+        *
+        * @test
+        */
+       public function getDataWithTypePath() {
+               $filenameIn = uniqid('someValue');
+               $filenameOut = uniqid('someValue');
+               $this->template->expects($this->atLeastOnce())->method('getFileName')->with($filenameIn)->will($this->returnValue($filenameOut));
+               $this->assertEquals($filenameOut, $this->cObj->getData('path:' . $filenameIn));
+       }
+
+       /**
+        * Checks if getData() works with type "parentRecordNumber"
+        *
+        * @test
+        */
+       public function getDataWithTypeParentRecordNumber() {
+               $recordNumber = rand();
+               $this->cObj->parentRecordNumber = $recordNumber;
+               $this->assertEquals($recordNumber, $this->cObj->getData('cobj:parentRecordNumber'));
+       }
+
+       /**
+        * Checks if getData() works with type "debug:rootLine"
+        *
+        * @test
+        */
+       public function getDataWithTypeDebugRootline() {
+               $rootline = array(
+                       0 => array('uid' => 1, 'title' => 'title1'),
+                       1 => array('uid' => 2, 'title' => 'title2'),
+                       2 => array('uid' => 3, 'title' => ''),
+               );
+               $expectedResult = '0uid1titletitle11uid2titletitle22uid3title';
+               $GLOBALS['TSFE']->tmpl->rootLine = $rootline;
+
+               $result = $this->cObj->getData('debug:rootLine');
+               $cleanedResult = strip_tags($result);
+               $cleanedResult = str_replace("\r", '', $cleanedResult);
+               $cleanedResult = str_replace("\n", '', $cleanedResult);
+               $cleanedResult = str_replace("\t", '', $cleanedResult);
+               $cleanedResult = str_replace(' ', '', $cleanedResult);
+
+               $this->assertEquals($expectedResult, $cleanedResult);
+       }
+
+       /**
+        * Checks if getData() works with type "debug:fullRootLine"
+        *
+        * @test
+        */
+       public function getDataWithTypeDebugFullRootline() {
+               $rootline = array(
+                       0 => array('uid' => 1, 'title' => 'title1'),
+                       1 => array('uid' => 2, 'title' => 'title2'),
+                       2 => array('uid' => 3, 'title' => ''),
+               );
+               $expectedResult = '0uid1titletitle11uid2titletitle22uid3title';
+               $GLOBALS['TSFE']->rootLine = $rootline;
+
+               $result = $this->cObj->getData('debug:fullRootLine');
+               $cleanedResult = strip_tags($result);
+               $cleanedResult = str_replace("\r", '', $cleanedResult);
+               $cleanedResult = str_replace("\n", '', $cleanedResult);
+               $cleanedResult = str_replace("\t", '', $cleanedResult);
+               $cleanedResult = str_replace(' ', '', $cleanedResult);
+
+               $this->assertEquals($expectedResult, $cleanedResult);
+       }
+
+       /**
+        * Checks if getData() works with type "debug:data"
+        *
+        * @test
+        */
+       public function getDataWithTypeDebugData() {
+               $key = uniqid('someKey');
+               $value = uniqid('someValue');
+               $this->cObj->data = array($key => $value);
+
+               $expectedResult = $key . $value;
+
+               $result = $this->cObj->getData('debug:data');
+               $cleanedResult = strip_tags($result);
+               $cleanedResult = str_replace("\r", '', $cleanedResult);
+               $cleanedResult = str_replace("\n", '', $cleanedResult);
+               $cleanedResult = str_replace("\t", '', $cleanedResult);
+               $cleanedResult = str_replace(' ', '', $cleanedResult);
+
+               $this->assertEquals($expectedResult, $cleanedResult);
+       }
+
+       /**
+        * Checks if getData() works with type "debug:register"
+        *
+        * @test
+        */
+       public function getDataWithTypeDebugRegister() {
+               $key = uniqid('someKey');
+               $value = uniqid('someValue');
+               $GLOBALS['TSFE']->register = array($key => $value);
+
+               $expectedResult = $key . $value;
+
+               $result = $this->cObj->getData('debug:register');
+               $cleanedResult = strip_tags($result);
+               $cleanedResult = str_replace("\r", '', $cleanedResult);
+               $cleanedResult = str_replace("\n", '', $cleanedResult);
+               $cleanedResult = str_replace("\t", '', $cleanedResult);
+               $cleanedResult = str_replace(' ', '', $cleanedResult);
+
+               $this->assertEquals($expectedResult, $cleanedResult);
+       }
+
+       /**
+        * Checks if getData() works with type "data:page"
+        *
+        * @test
+        */
+       public function getDataWithTypeDebugPage() {
+               $uid = rand();
+               $GLOBALS['TSFE']->page = array('uid' => $uid);
+
+               $expectedResult = 'uid' . $uid;
+
+               $result = $this->cObj->getData('debug:page');
+               $cleanedResult = strip_tags($result);
+               $cleanedResult = str_replace("\r", '', $cleanedResult);
+               $cleanedResult = str_replace("\n", '', $cleanedResult);
+               $cleanedResult = str_replace("\t", '', $cleanedResult);
+               $cleanedResult = str_replace(' ', '', $cleanedResult);
+
+               $this->assertEquals($expectedResult, $cleanedResult);
+       }
 }
 
-?>
+?>
\ No newline at end of file