‪TYPO3CMS  10.4
ServicesListReportTest.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;
21 use Prophecy\Prophecy\ObjectProphecy;
28 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
29 
33 class ‪ServicesListReportTest extends UnitTestCase
34 {
38  protected ‪$subject;
39 
43  public function ‪setUp(): void
44  {
45  parent::setUp();
46  ‪$GLOBALS['LANG'] = $this->‪languageServiceProphecy()->reveal();
47  $this->subject = new ‪ServicesListReport(
48  $this->‪reportControllerProphecy()->reveal()
49  );
50  }
51 
56  {
57  $standaloneViewProphecy = $this->‪standaloneViewProphecy();
58 
59  $this->subject->getReport();
60 
61  $standaloneViewProphecy
62  ->assignMultiple(Argument::withEntry('servicesList', []))
63  ->shouldHaveBeenCalled();
64  $standaloneViewProphecy
65  ->assignMultiple(Argument::withKey('searchPaths'))
66  ->shouldHaveBeenCalled();
67  }
68 
73  private function ‪standaloneViewProphecy(): ObjectProphecy
74  {
75  $templatePath = GeneralUtility::getFileAbsFileName(
76  'EXT:reports/Resources/Private/Templates/ServicesListReport.html'
77  );
78  $serverRequestProphecy = $this->prophesize(Request::class);
80  $standaloneViewProphecy = $this->prophesize(StandaloneView::class);
81  $standaloneViewProphecy->getRequest()->willReturn($serverRequestProphecy->reveal());
82  $standaloneViewProphecy->setTemplatePathAndFilename($templatePath)->shouldBeCalled();
83  $standaloneViewProphecy->assignMultiple(Argument::any())->willReturn($standaloneViewProphecy->reveal());
84  $standaloneViewProphecy->render()->willReturn('<p>Template output</p>');
85  GeneralUtility::addInstance(StandaloneView::class, $standaloneViewProphecy->reveal());
86 
87  return $standaloneViewProphecy;
88  }
89 
93  private function ‪languageServiceProphecy(): ObjectProphecy
94  {
95  $languageServiceProphecy = $this->prophesize(LanguageService::class);
96  $languageServiceProphecy
97  ->includeLLFile('EXT:reports/Resources/Private/Language/locallang_servicereport.xlf')
98  ->willReturn(null)
99  ->shouldBeCalled();
100  $languageServiceProphecy->getLL(Argument::any())->willReturn('translation string');
101  return $languageServiceProphecy;
102  }
103 
107  private function ‪reportControllerProphecy(): ObjectProphecy
108  {
109  $reportControllerProphecy = $this->prophesize(ReportController::class);
110  return $reportControllerProphecy;
111  }
112 }
‪TYPO3\CMS\Reports\Tests\Unit\Report\ServicesListReportTest\languageServiceProphecy
‪ObjectProphecy languageServiceProphecy()
Definition: ServicesListReportTest.php:92
‪TYPO3\CMS\Reports\Tests\Unit\Report\ServicesListReportTest\setUp
‪setUp()
Definition: ServicesListReportTest.php:42
‪TYPO3\CMS\Reports\Tests\Unit\Report\ServicesListReportTest
Definition: ServicesListReportTest.php:34
‪TYPO3\CMS\Reports\Report\ServicesListReport
Definition: ServicesListReport.php:30
‪TYPO3\CMS\Reports\Tests\Unit\Report\ServicesListReportTest\reportControllerProphecy
‪ObjectProphecy reportControllerProphecy()
Definition: ServicesListReportTest.php:106
‪TYPO3\CMS\Reports\Tests\Unit\Report
Definition: ServicesListReportTest.php:18
‪TYPO3\CMS\Reports\Tests\Unit\Report\ServicesListReportTest\$subject
‪ServicesListReport $subject
Definition: ServicesListReportTest.php:37
‪TYPO3\CMS\Fluid\View\StandaloneView
Definition: StandaloneView.php:34
‪TYPO3\CMS\Reports\Tests\Unit\Report\ServicesListReportTest\getReportCollectsRelevantDataToAssignThemToTemplateForResponse
‪getReportCollectsRelevantDataToAssignThemToTemplateForResponse()
Definition: ServicesListReportTest.php:54
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:42
‪TYPO3\CMS\Reports\Tests\Unit\Report\ServicesListReportTest\standaloneViewProphecy
‪ObjectProphecy standaloneViewProphecy()
Definition: ServicesListReportTest.php:72
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Extbase\Mvc\Request
Definition: Request.php:31
‪TYPO3\CMS\Reports\Controller\ReportController
Definition: ReportController.php:39