‪TYPO3CMS  11.5
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\PhpUnit\ProphecyTrait;
22 use Prophecy\Prophecy\ObjectProphecy;
29 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
30 
34 class ‪ServicesListReportTest extends UnitTestCase
35 {
36  use ProphecyTrait;
37 
39 
40  public function ‪setUp(): void
41  {
42  parent::setUp();
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 
69  private function ‪standaloneViewProphecy(): ObjectProphecy
70  {
71  $templatePath = GeneralUtility::getFileAbsFileName(
72  'EXT:reports/Resources/Private/Templates/ServicesListReport.html'
73  );
74  $serverRequestProphecy = $this->prophesize(Request::class);
75  $standaloneViewProphecy = $this->prophesize(StandaloneView::class);
76  $standaloneViewProphecy->getRequest()->willReturn($serverRequestProphecy->reveal());
77  $standaloneViewProphecy->setTemplatePathAndFilename($templatePath)->shouldBeCalled();
78  $standaloneViewProphecy->assignMultiple(Argument::any())->willReturn($standaloneViewProphecy->reveal());
79  $standaloneViewProphecy->render()->willReturn('<p>Template output</p>');
80  GeneralUtility::addInstance(StandaloneView::class, $standaloneViewProphecy->reveal());
81 
82  return $standaloneViewProphecy;
83  }
84 
88  private function ‪languageServiceProphecy(): ObjectProphecy
89  {
90  $languageServiceProphecy = $this->prophesize(LanguageService::class);
91  $languageServiceProphecy
92  ->includeLLFile('EXT:reports/Resources/Private/Language/locallang_servicereport.xlf')
93  ->willReturn(null)
94  ->shouldBeCalled();
95  $languageServiceProphecy->getLL(Argument::any())->willReturn('translation string');
96  return $languageServiceProphecy;
97  }
98 
102  private function ‪reportControllerProphecy(): ObjectProphecy
103  {
104  return $this->prophesize(ReportController::class);
105  }
106 }
‪TYPO3\CMS\Reports\Tests\Unit\Report\ServicesListReportTest\languageServiceProphecy
‪ObjectProphecy languageServiceProphecy()
Definition: ServicesListReportTest.php:87
‪TYPO3\CMS\Reports\Tests\Unit\Report\ServicesListReportTest\setUp
‪setUp()
Definition: ServicesListReportTest.php:39
‪TYPO3\CMS\Reports\Tests\Unit\Report\ServicesListReportTest
Definition: ServicesListReportTest.php:35
‪TYPO3\CMS\Reports\Report\ServicesListReport
Definition: ServicesListReport.php:30
‪TYPO3\CMS\Reports\Tests\Unit\Report\ServicesListReportTest\reportControllerProphecy
‪ObjectProphecy reportControllerProphecy()
Definition: ServicesListReportTest.php:101
‪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:31
‪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:25
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:42
‪TYPO3\CMS\Reports\Tests\Unit\Report\ServicesListReportTest\standaloneViewProphecy
‪ObjectProphecy standaloneViewProphecy()
Definition: ServicesListReportTest.php:68
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Extbase\Mvc\Request
Definition: Request.php:39
‪TYPO3\CMS\Reports\Controller\ReportController
Definition: ReportController.php:42