‪TYPO3CMS  10.4
TypoScriptFrontendControllerTest.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 
29 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
30 
34 class ‪TypoScriptFrontendControllerTest extends UnitTestCase
35 {
39  protected ‪$resetSingletonInstances = true;
40 
44  protected ‪$subject;
45 
46  protected function ‪setUp(): void
47  {
48  parent::setUp();
49  $this->subject = $this->getAccessibleMock(TypoScriptFrontendController::class, ['dummy'], [], '', false);
50  $this->subject->_set('context', new ‪Context());
51  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = '170928423746123078941623042360abceb12341234231';
52 
53  $pageRepository = $this->getMockBuilder(PageRepository::class)->getMock();
54  $this->subject->sys_page = $pageRepository;
55 
56  $pageRenderer = $this->getMockBuilder(PageRenderer::class)->getMock();
57  $this->subject->_set('pageRenderer', $pageRenderer);
58  }
59 
61  {
62  return [
63  'no extra params' => [
64  [],
65  false,
66  ],
67  'with required param' => [
68  [
69  'abc' => 1,
70  ],
71  true,
72  ],
73  'with required params' => [
74  [
75  'abc' => 1,
76  'abcd' => 1,
77  ],
78  true,
79  ],
80  'with not required param' => [
81  [
82  'fbclid' => 1,
83  ],
84  false,
85  ],
86  'with not required params' => [
87  [
88  'fbclid' => 1,
89  'gclid' => 1,
90  'foo' => [
91  'bar' => 1,
92  ],
93  ],
94  false,
95  ],
96  'with combined params' => [
97  [
98  'abc' => 1,
99  'fbclid' => 1,
100  ],
101  true,
102  ],
103  'with multiple combined params' => [
104  [
105  'abc' => 1,
106  'fbclid' => 1,
107  'abcd' => 1,
108  'gclid' => 1
109  ],
110  true,
111  ]
112  ];
113  }
114 
122  public function ‪requireCacheHashValidateRelevantParameters(array $remainingArguments, bool $expected): void
123  {
124  ‪$GLOBALS['TYPO3_REQUEST'] = new ServerRequest();
125  ‪$GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFoundOnCHashError'] = true;
126  ‪$GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParameters'] = ['gclid', 'fbclid', 'foo[bar]'];
127 
128  $this->subject = $this->getAccessibleMock(TypoScriptFrontendController::class, ['dummy'], [], '', false);
129  $this->subject->_set('pageArguments', new PageArguments(1, '0', ['tx_test' => 1], ['tx_test' => 1], $remainingArguments));
130 
131  if ($expected) {
132  $typo3InformationProphecy = $this->prophesize(Typo3Information::class);
133  $typo3InformationProphecy->getCopyrightYear()->willReturn('1999-20XX');
134  GeneralUtility::addInstance(Typo3Information::class, $typo3InformationProphecy->reveal());
135  static::expectException(ImmediateResponseException::class);
136  }
137  $this->subject->reqCHash();
138  }
139 }
‪TYPO3\CMS\Core\Routing\PageArguments
Definition: PageArguments.php:26
‪TYPO3\CMS\Core\Information\Typo3Information
Definition: Typo3Information.php:26
‪TYPO3\CMS\Core\Context\Context
Definition: Context.php:53
‪TYPO3\CMS\Core\Page\PageRenderer
Definition: PageRenderer.php:42
‪TYPO3\CMS\Frontend\Tests\UnitDeprecated\Controller\TypoScriptFrontendControllerTest\setUp
‪setUp()
Definition: TypoScriptFrontendControllerTest.php:44
‪TYPO3\CMS\Frontend\Tests\UnitDeprecated\Controller\TypoScriptFrontendControllerTest\requireCacheHashValidateRelevantParameters
‪requireCacheHashValidateRelevantParameters(array $remainingArguments, bool $expected)
Definition: TypoScriptFrontendControllerTest.php:120
‪TYPO3\CMS\Core\Http\ServerRequest
Definition: ServerRequest.php:37
‪TYPO3\CMS\Frontend\Tests\UnitDeprecated\Controller\TypoScriptFrontendControllerTest
Definition: TypoScriptFrontendControllerTest.php:35
‪TYPO3\CMS\Frontend\Tests\UnitDeprecated\Controller\TypoScriptFrontendControllerTest\requireCacheHashValidateRelevantParametersDataProvider
‪requireCacheHashValidateRelevantParametersDataProvider()
Definition: TypoScriptFrontendControllerTest.php:58
‪TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
Definition: TypoScriptFrontendController.php:98
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Frontend\Tests\UnitDeprecated\Controller
Definition: TypoScriptFrontendControllerTest.php:18
‪TYPO3\CMS\Core\Domain\Repository\PageRepository
Definition: PageRepository.php:52
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Core\Http\ImmediateResponseException
Definition: ImmediateResponseException.php:30
‪TYPO3\CMS\Frontend\Tests\UnitDeprecated\Controller\TypoScriptFrontendControllerTest\$subject
‪PHPUnit Framework MockObject MockObject TYPO3 TestingFramework Core AccessibleObjectInterface TypoScriptFrontendController $subject
Definition: TypoScriptFrontendControllerTest.php:42
‪TYPO3\CMS\Frontend\Tests\UnitDeprecated\Controller\TypoScriptFrontendControllerTest\$resetSingletonInstances
‪bool $resetSingletonInstances
Definition: TypoScriptFrontendControllerTest.php:38