‪TYPO3CMS  9.5
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 
19 use Prophecy\Argument;
26 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
27 
28 class ‪FileBrowserTest extends UnitTestCase
29 {
30 
35  {
36  [$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->getTSConfig()->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->getTSConfig()->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 }
‪TYPO3\CMS\Recordlist\Tests\Unit\Browser\FileBrowserTest
Definition: FileBrowserTest.php:29
‪TYPO3\CMS\Recordlist\Tests\Unit\Browser\FileBrowserTest\setupProphecies
‪array setupProphecies()
Definition: FileBrowserTest.php:51
‪TYPO3\CMS\Recordlist\Browser\FileBrowser
Definition: FileBrowser.php:40
‪TYPO3\CMS\Recordlist\Tests\Unit\Browser\FileBrowserTest\renderGetsUserDefaultUploadFolderForCurrentPageData
‪renderGetsUserDefaultUploadFolderForCurrentPageData()
Definition: FileBrowserTest.php:34
‪TYPO3\CMS\Backend\Tree\View\ElementBrowserFolderTreeView
Definition: ElementBrowserFolderTreeView.php:31
‪TYPO3\CMS\Recordlist\Tests\Unit\Browser
Definition: FileBrowserTest.php:4
‪TYPO3\CMS\Backend\Template\DocumentTemplate
Definition: DocumentTemplate.php:48
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:45
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:29
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45