TYPO3 CMS  TYPO3_7-6
AdminPanelViewTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
21 {
25  protected function setUp()
26  {
27  $GLOBALS['LANG'] = $this->getMock(\TYPO3\CMS\Lang\LanguageService::class, [], [], '', false);
28  }
29 
34  {
35  $strTime = '2013-01-01 01:00:00';
36  $timestamp = strtotime($strTime);
37 
38  $backendUser = $this->getMock(\TYPO3\CMS\Core\Authentication\BackendUserAuthentication::class);
39  $backendUser->uc['TSFE_adminConfig']['preview_simulateDate'] = $timestamp;
40  unset($backendUser->extAdminConfig['override.']['preview.']);
41  unset($backendUser->extAdminConfig['override.']['preview']);
42  $GLOBALS['BE_USER'] = $backendUser;
43 
44  $adminPanelMock = $this->getMock(\TYPO3\CMS\Frontend\View\AdminPanelView::class, ['isAdminModuleEnabled', 'isAdminModuleOpen'], [], '', false);
45  $adminPanelMock->expects($this->any())->method('isAdminModuleEnabled')->will($this->returnValue(true));
46  $adminPanelMock->expects($this->any())->method('isAdminModuleOpen')->will($this->returnValue(true));
47 
48  $timestampReturned = $adminPanelMock->extGetFeAdminValue('preview', 'simulateDate');
49  $this->assertEquals($timestamp, $timestampReturned);
50  }
51 
53  // Test concerning extendAdminPanel hook
55 
60  public function extendAdminPanelHookThrowsExceptionIfHookClassDoesNotImplementInterface()
61  {
62  $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_adminpanel.php']['extendAdminPanel'][] = \TYPO3\CMS\Frontend\Tests\Unit\Fixtures\AdminPanelHookWithoutInterfaceFixture::class;
64  $adminPanelMock = $this->getMock(\TYPO3\CMS\Frontend\View\AdminPanelView::class, ['dummy'], [], '', false);
65  $adminPanelMock->display();
66  }
67 
71  public function extendAdminPanelHookCallsExtendAdminPanelMethodOfHook()
72  {
73  $hookClass = $this->getUniqueId('tx_coretest');
74  $hookMock = $this->getMock(\TYPO3\CMS\Frontend\View\AdminPanelViewHookInterface::class, [], [], $hookClass);
75  $GLOBALS['T3_VAR']['getUserObj'][$hookClass] = $hookMock;
76  $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_adminpanel.php']['extendAdminPanel'][] = $hookClass;
78  $adminPanelMock = $this->getMock(\TYPO3\CMS\Frontend\View\AdminPanelView::class, ['extGetLL'], [], '', false);
79  $hookMock->expects($this->once())->method('extendAdminPanel')->with($this->isType('string'), $this->isInstanceOf(\TYPO3\CMS\Frontend\View\AdminPanelView::class));
80  $adminPanelMock->display();
81  }
82 }
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']