‪TYPO3CMS  9.5
ServicesListReportTest.php
Go to the documentation of this file.
1 <?php
2 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 
18 use Prophecy\Argument;
19 use Prophecy\Prophecy\ObjectProphecy;
26 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
27 
31 class ‪ServicesListReportTest extends UnitTestCase
32 {
36  protected ‪$subject;
37 
41  public function ‪setUp()
42  {
43  ‪$GLOBALS['LANG'] = $this->‪languageServiceProphecy()->reveal();
44  $this->subject = new ‪ServicesListReport(
45  $this->‪reportControllerProphecy()->reveal()
46  );
47  }
48 
53  {
54  $standaloneViewProphecy = $this->‪standaloneViewProphecy();
55 
56  $this->subject->getReport();
57 
58  $standaloneViewProphecy
59  ->assignMultiple(Argument::withEntry('servicesList', []))
60  ->shouldHaveBeenCalled();
61  $standaloneViewProphecy
62  ->assignMultiple(Argument::withKey('searchPaths'))
63  ->shouldHaveBeenCalled();
64  }
65 
70  private function ‪standaloneViewProphecy(): ObjectProphecy
71  {
72  $templatePath = GeneralUtility::getFileAbsFileName(
73  'EXT:reports/Resources/Private/Templates/ServicesListReport.html'
74  );
75  $serverRequestProphecy = $this->prophesize(Request::class);
77  $standaloneViewProphecy = $this->prophesize(StandaloneView::class);
78  $standaloneViewProphecy->getRequest()->willReturn($serverRequestProphecy->reveal());
79  $standaloneViewProphecy->setTemplatePathAndFilename($templatePath)->shouldBeCalled();
80  $standaloneViewProphecy->assignMultiple(Argument::any())->willReturn($standaloneViewProphecy->reveal());
81  $standaloneViewProphecy->render()->willReturn('<p>Template output</p>');
82  GeneralUtility::addInstance(StandaloneView::class, $standaloneViewProphecy->reveal());
83 
84  return $standaloneViewProphecy;
85  }
86 
90  private function ‪languageServiceProphecy(): ObjectProphecy
91  {
92  $languageServiceProphecy = $this->prophesize(LanguageService::class);
93  $languageServiceProphecy
94  ->includeLLFile('EXT:reports/Resources/Private/Language/locallang_servicereport.xlf')
95  ->willReturn(null)
96  ->shouldBeCalled();
97  $languageServiceProphecy->getLL(Argument::any())->willReturn('translation string');
98  return $languageServiceProphecy;
99  }
100 
104  private function ‪reportControllerProphecy(): ObjectProphecy
105  {
106  $reportControllerProphecy = $this->prophesize(ReportController::class);
107  return $reportControllerProphecy;
108  }
109 }
‪TYPO3\CMS\Reports\Tests\Unit\Report\ServicesListReportTest\languageServiceProphecy
‪ObjectProphecy languageServiceProphecy()
Definition: ServicesListReportTest.php:89
‪TYPO3\CMS\Reports\Tests\Unit\Report\ServicesListReportTest\setUp
‪setUp()
Definition: ServicesListReportTest.php:40
‪TYPO3\CMS\Reports\Tests\Unit\Report\ServicesListReportTest
Definition: ServicesListReportTest.php:32
‪TYPO3\CMS\Reports\Report\ServicesListReport
Definition: ServicesListReport.php:29
‪TYPO3\CMS\Reports\Tests\Unit\Report\ServicesListReportTest\reportControllerProphecy
‪ObjectProphecy reportControllerProphecy()
Definition: ServicesListReportTest.php:103
‪TYPO3\CMS\Reports\Tests\Unit\Report
Definition: ServicesListReportTest.php:3
‪TYPO3\CMS\Reports\Tests\Unit\Report\ServicesListReportTest\$subject
‪ServicesListReport $subject
Definition: ServicesListReportTest.php:35
‪TYPO3\CMS\Fluid\View\StandaloneView
Definition: StandaloneView.php:32
‪TYPO3\CMS\Reports\Tests\Unit\Report\ServicesListReportTest\getReportCollectsRelevantDataToAssignThemToTemplateForResponse
‪getReportCollectsRelevantDataToAssignThemToTemplateForResponse()
Definition: ServicesListReportTest.php:51
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:29
‪TYPO3\CMS\Reports\Tests\Unit\Report\ServicesListReportTest\standaloneViewProphecy
‪ObjectProphecy standaloneViewProphecy()
Definition: ServicesListReportTest.php:69
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Extbase\Mvc\Request
Definition: Request.php:23
‪TYPO3\CMS\Reports\Controller\ReportController
Definition: ReportController.php:37