[BUGFIX] Simulate time in TYPO3 admin panel broken 95/26895/6
authorPeter Niederlag <peter.niederlag@typo3.org>
Wed, 14 Aug 2013 10:09:39 +0000 (12:09 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Tue, 21 Jan 2014 22:48:16 +0000 (23:48 +0100)
* Test typeof TBE_EDITOR == "undefined" in jsfunc.evalfield
* Thanks to Stefan Neufeind/Markus Klein for adding the Unittest

Resolves: #55093
Releases: 6.2, 6.1, 6.0
Change-Id: I2cc8a5ca3dd6251f89618d3615c1457938ff135e
Reviewed-on: https://review.typo3.org/26895
Reviewed-by: Markus Klein
Tested-by: Markus Klein
Reviewed-by: Henrik Ziegenhain
Tested-by: Henrik Ziegenhain
Reviewed-by: Wouter Wolters
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
typo3/sysext/backend/Resources/Public/JavaScript/jsfunc.evalfield.js
typo3/sysext/frontend/Tests/Unit/View/AdminPanelViewTest.php

index 99bc0dd..48c5828 100644 (file)
@@ -62,7 +62,7 @@ function evalFunc_evalObjValue(FObj,value) {
        var theEvalType = (FObj.evallist) ? this.split(evallist, ",", index) : false;
        var newValue=value;
        while (theEvalType) {
-               if (TBE_EDITOR.customEvalFunctions[theEvalType] && typeof TBE_EDITOR.customEvalFunctions[theEvalType] == 'function') {
+               if (typeof TBE_EDITOR == 'function' && TBE_EDITOR.customEvalFunctions[theEvalType] && typeof TBE_EDITOR.customEvalFunctions[theEvalType] == 'function') {
                        newValue = TBE_EDITOR.customEvalFunctions[theEvalType](newValue);
                } else {
                        newValue = evalFunc.input(theEvalType, newValue);
index f04acd6..9bbb4d9 100644 (file)
@@ -36,6 +36,27 @@ class AdminPanelViewTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $GLOBALS['LANG'] = $this->getMock('TYPO3\\CMS\\Lang\\LanguageService', array(), array(), '', FALSE);
        }
 
+       /**
+        * @test
+        */
+       public function extGetFeAdminValueReturnsTimestamp() {
+               $strTime = '2013-01-01 01:00:00';
+               $timestamp = strtotime($strTime);
+
+               $backendUser = $this->getMock('TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication');
+               $backendUser->uc['TSFE_adminConfig']['preview_simulateDate'] = $timestamp;
+               unset($backendUser->extAdminConfig['override.']['preview.']);
+               unset($backendUser->extAdminConfig['override.']['preview']);
+               $GLOBALS['BE_USER'] = $backendUser;
+
+               $adminPanelMock = $this->getMock('TYPO3\\CMS\\Frontend\\View\\AdminPanelView', array('isAdminModuleEnabled','isAdminModuleOpen'), array(), '', FALSE);
+               $adminPanelMock->expects($this->any())->method('isAdminModuleEnabled')->will($this->returnValue(TRUE));
+               $adminPanelMock->expects($this->any())->method('isAdminModuleOpen')->will($this->returnValue(TRUE));
+
+               $timestampReturned = $adminPanelMock->extGetFeAdminValue('preview', 'simulateDate');
+               $this->assertEquals($timestamp, $timestampReturned);
+       }
+
        /////////////////////////////////////////////
        // Test concerning extendAdminPanel hook
        /////////////////////////////////////////////