TYPO3 CMS  TYPO3_7-6
ModuleDataStorageServiceTest.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  public function loadModuleDataReturnsModuleDataObjectForEmptyModuleData()
26  {
27  // The test calls several static dependencies that can not be mocked and
28  // call database in the end, so we need to mock the database here.
29  $GLOBALS['TYPO3_DB'] = $this->getMock(\TYPO3\CMS\Core\Database\DatabaseConnection::class, [], [], '', false);
30 
31  // Simulate empty module data
32  $GLOBALS['BE_USER'] = $this->getMock(\TYPO3\CMS\Core\Authentication\BackendUserAuthentication::class, [], [], '', false);
33  $GLOBALS['BE_USER']->uc = [];
34  $GLOBALS['BE_USER']->uc['moduleData'] = [];
35 
37  $subject = $this->getAccessibleMock(\TYPO3\CMS\Beuser\Service\ModuleDataStorageService::class, ['dummy'], [], '', false);
38  $objectManagerMock = $this->getMock(\TYPO3\CMS\Extbase\Object\ObjectManager::class, [], [], '', false);
39  $moduleDataMock = $this->getMock(\TYPO3\CMS\Beuser\Domain\Model\ModuleData::class, [], [], '', false);
40  $objectManagerMock
41  ->expects($this->once())
42  ->method('get')
43  ->with(\TYPO3\CMS\Beuser\Domain\Model\ModuleData::class)
44  ->will($this->returnValue($moduleDataMock));
45  $subject->_set('objectManager', $objectManagerMock);
46 
47  $this->assertSame($moduleDataMock, $subject->loadModuleData());
48  }
49 }
getAccessibleMock( $originalClassName, $methods=[], array $arguments=[], $mockClassName='', $callOriginalConstructor=true, $callOriginalClone=true, $callAutoload=true)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']