TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
AdminPanelViewTest.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Frontend\Tests\Unit\View;
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  */
17 
22 {
26  protected function setUp()
27  {
28  $GLOBALS['LANG'] = $this->createMock(\TYPO3\CMS\Lang\LanguageService::class);
29  }
30 
35  {
36  $strTime = '2013-01-01 01:00:00';
37  $timestamp = strtotime($strTime);
38 
39  $backendUser = $this->getMockBuilder(\TYPO3\CMS\Core\Authentication\BackendUserAuthentication::class)->getMock();
40  $backendUser->uc['TSFE_adminConfig']['preview_simulateDate'] = $timestamp;
41  unset($backendUser->extAdminConfig['override.']['preview.']);
42  unset($backendUser->extAdminConfig['override.']['preview']);
43  $GLOBALS['BE_USER'] = $backendUser;
44 
45  $adminPanelMock = $this->getMockBuilder(\TYPO3\CMS\Frontend\View\AdminPanelView::class)
46  ->setMethods(['isAdminModuleEnabled', 'isAdminModuleOpen'])
47  ->disableOriginalConstructor()
48  ->getMock();
49  $adminPanelMock->expects($this->any())->method('isAdminModuleEnabled')->will($this->returnValue(true));
50  $adminPanelMock->expects($this->any())->method('isAdminModuleOpen')->will($this->returnValue(true));
51 
52  $timestampReturned = $adminPanelMock->extGetFeAdminValue('preview', 'simulateDate');
53  $this->assertEquals($timestamp, $timestampReturned);
54  }
55 
57  // Test concerning extendAdminPanel hook
59 
63  public function extendAdminPanelHookThrowsExceptionIfHookClassDoesNotImplementInterface()
64  {
65  $this->expectException(\UnexpectedValueException::class);
66  $this->expectExceptionCode(1311942539);
67  $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_adminpanel.php']['extendAdminPanel'][] = \TYPO3\CMS\Frontend\Tests\Unit\Fixtures\AdminPanelHookWithoutInterfaceFixture::class;
69  $adminPanelMock = $this->getMockBuilder(\TYPO3\CMS\Frontend\View\AdminPanelView::class)
70  ->setMethods(['dummy'])
71  ->disableOriginalConstructor()
72  ->getMock();
73  $adminPanelMock->display();
74  }
75 
79  public function extendAdminPanelHookCallsExtendAdminPanelMethodOfHook()
80  {
81  $hookClass = $this->getUniqueId('tx_coretest');
82  $hookMock = $this->getMockBuilder(\TYPO3\CMS\Frontend\View\AdminPanelViewHookInterface::class)
83  ->setMockClassName($hookClass)
84  ->getMock();
85  GeneralUtility::addInstance($hookClass, $hookMock);
86  $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_adminpanel.php']['extendAdminPanel'][] = $hookClass;
88  $adminPanelMock = $this->getMockBuilder(\TYPO3\CMS\Frontend\View\AdminPanelView::class)
89  ->setMethods(['extGetLL'])
90  ->disableOriginalConstructor()
91  ->getMock();
92  $hookMock->expects($this->once())->method('extendAdminPanel')->with($this->isType('string'), $this->isInstanceOf(\TYPO3\CMS\Frontend\View\AdminPanelView::class));
93  $adminPanelMock->display();
94  }
95 }
if(TYPO3_MODE=== 'BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
static addInstance($className, $instance)