‪TYPO3CMS  10.4
FileBrowserTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Prophecy\Argument;
32 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
33 
34 class ‪FileBrowserTest extends UnitTestCase
35 {
40  {
41  [$moduleTemplate, $beUser] = $this->‪setupProphecies();
42 
43  $bparams = '|||gif,png,svg|data-4-pages-4-nav_icon-sys_file_reference';
44  $fileBrowser = $this->getAccessibleMock(FileBrowser::class, ['dummy'], [], '', false);
45  $fileBrowser->_set('bparams', $bparams);
46  $fileBrowser->_set('moduleTemplate', $moduleTemplate);
47  $fileBrowser->render();
48 
49  $beUser->getTSConfig()->shouldHaveBeenCalled();
50  $beUser->getDefaultUploadFolder(4, 'pages', 'nav_icon')->shouldHaveBeenCalled();
51  }
52 
56  private function ‪setupProphecies(): array
57  {
58  $browserFolderTreeView = $this->prophesize(ElementBrowserFolderTreeView::class);
59  GeneralUtility::addInstance(ElementBrowserFolderTreeView::class, $browserFolderTreeView->reveal());
60 
61  $flashMessageService = $this->prophesize(FlashMessageService::class);
62  $flashMessageService->getMessageQueueByIdentifier()->willReturn($this->prophesize(FlashMessageQueue::class)->reveal());
63  $moduleTemplate = $this->getAccessibleMock(ModuleTemplate::class, ['setupPage'], [], '', false);
64  $moduleTemplate->_set('flashMessageService', $flashMessageService->reveal());
65  $moduleTemplate->_set('view', $this->prophesize(StandaloneView::class)->reveal());
66  $moduleTemplate->_set('docHeaderComponent', $this->prophesize(DocHeaderComponent::class)->reveal());
67  $moduleTemplate->_set('pageRenderer', $this->prophesize(PageRenderer::class)->reveal());
68 
69  $lang = $this->prophesize(LanguageService::class);
70  ‪$GLOBALS['LANG'] = $lang->reveal();
71 
72  $beUser = $this->prophesize(BackendUserAuthentication::class);
73  $beUser->getFileStorages()->willReturn([]);
74  $beUser->getTSConfig()->willReturn('');
75  $beUser->getModuleData(Argument::cetera())->willReturn([]);
76  $beUser->getDefaultUploadFolder(Argument::cetera())->willReturn('');
77  ‪$GLOBALS['BE_USER'] = $beUser->reveal();
78  return [$moduleTemplate, $beUser];
79  }
80 }
‪TYPO3\CMS\Backend\Template\Components\DocHeaderComponent
Definition: DocHeaderComponent.php:24
‪TYPO3\CMS\Recordlist\Tests\Unit\Browser\FileBrowserTest
Definition: FileBrowserTest.php:35
‪TYPO3\CMS\Recordlist\Tests\Unit\Browser\FileBrowserTest\setupProphecies
‪array setupProphecies()
Definition: FileBrowserTest.php:56
‪TYPO3\CMS\Recordlist\Browser\FileBrowser
Definition: FileBrowser.php:42
‪TYPO3\CMS\Recordlist\Tests\Unit\Browser\FileBrowserTest\renderGetsUserDefaultUploadFolderForCurrentPageData
‪renderGetsUserDefaultUploadFolderForCurrentPageData()
Definition: FileBrowserTest.php:39
‪TYPO3\CMS\Backend\Tree\View\ElementBrowserFolderTreeView
Definition: ElementBrowserFolderTreeView.php:31
‪TYPO3\CMS\Backend\Template\ModuleTemplate
Definition: ModuleTemplate.php:43
‪TYPO3\CMS\Recordlist\Tests\Unit\Browser
Definition: FileBrowserTest.php:18
‪TYPO3\CMS\Core\Page\PageRenderer
Definition: PageRenderer.php:42
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪TYPO3\CMS\Fluid\View\StandaloneView
Definition: StandaloneView.php:34
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:42
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Core\Messaging\FlashMessageQueue
Definition: FlashMessageQueue.php:29
‪TYPO3\CMS\Core\Messaging\FlashMessageService
Definition: FlashMessageService.php:27