TYPO3 CMS  TYPO3_8-7
FileBrowserTest.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
3 
5 
6 /*
7  * This file is part of the TYPO3 CMS project.
8  *
9  * It is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License, either version 2
11  * of the License, or any later version.
12  *
13  * For the full copyright and license information, please read the
14  * LICENSE.txt file that was distributed with this source code.
15  *
16  * The TYPO3 project - inspiring people to share!
17  */
18 
27 
28 class FileBrowserTest extends UnitTestCase
29 {
30 
35  {
36  list($documentTemplate, $beUser) = $this->setupProphecies();
37 
38  $bparams = '|||gif,png,svg|data-4-pages-4-nav_icon-sys_file_reference|inline.checkUniqueElement||inline.importElement';
39  $fileBrowser = $this->getAccessibleMock(FileBrowser::class, ['initDocumentTemplate'], [], '', false);
40  $fileBrowser->_set('bparams', $bparams);
41  $fileBrowser->_set('doc', $documentTemplate->reveal());
42  $fileBrowser->render();
43 
44  $beUser->getTSConfigVal(Argument::cetera())->shouldHaveBeenCalled();
45  $beUser->getDefaultUploadFolder(4, 'pages', 'nav_icon')->shouldHaveBeenCalled();
46  }
47 
51  private function setupProphecies(): array
52  {
53  $browserFolderTreeView = $this->prophesize(ElementBrowserFolderTreeView::class);
54  GeneralUtility::addInstance(ElementBrowserFolderTreeView::class, $browserFolderTreeView->reveal());
55 
56  $documentTemplate = $this->prophesize(DocumentTemplate::class);
57  $lang = $this->prophesize(LanguageService::class);
58  $GLOBALS['LANG'] = $lang->reveal();
59 
60  $beUser = $this->prophesize(BackendUserAuthentication::class);
61  $beUser->getFileStorages()->willReturn([]);
62  $beUser->getTSConfigVal(Argument::cetera())->willReturn('');
63  $beUser->getModuleData(Argument::cetera())->willReturn([]);
64  $beUser->getDefaultUploadFolder(Argument::cetera())->willReturn('');
65  $GLOBALS['BE_USER'] = $beUser->reveal();
66  return [$documentTemplate, $beUser];
67  }
68 }
static addInstance($className, $instance)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']