‪TYPO3CMS  11.5
DefaultExtbaseControllerTest.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 TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
21 
26 {
31  {
32  return [
33  '*::*' => [
34  '&tx_testing_link[value]=1&tx_testing_link[excludedValue]=random',
35  'https://acme.us/welcome/link/index/one?tx_testing_link%5BexcludedValue%5D=random',
36  ],
37  '*::list' => [
38  '&tx_testing_link[action]=list&tx_testing_link[value]=1&tx_testing_link[excludedValue]=random',
39  'https://acme.us/welcome/link/list/one?tx_testing_link%5BexcludedValue%5D=random',
40  ],
41  'Link::*' => [
42  // correctly falling back to defaultController here
43  '&tx_testing_link[controller]=Link&tx_testing_link[value]=1&tx_testing_link[excludedValue]=random',
44  'https://acme.us/welcome/link/index/one?tx_testing_link%5BexcludedValue%5D=random',
45  ],
46  'Page::*' => [
47  // correctly falling back to defaultController here
48  '&tx_testing_link[controller]=Page&tx_testing_link[value]=1&tx_testing_link[excludedValue]=random',
49  'https://acme.us/welcome/link/index/one?tx_testing_link%5BexcludedValue%5D=random',
50  ],
51  'Page::show' => [
52  '&tx_testing_link[controller]=Page&tx_testing_link[action]=show&tx_testing_link[value]=1&tx_testing_link[excludedValue]=random',
53  'https://acme.us/welcome/page/show/one?tx_testing_link%5BexcludedValue%5D=random',
54  ],
55  ];
56  }
57 
66  public function ‪defaultExtbaseControllerActionNamesAreAppliedWithAdditionalNonMappedQueryArguments(string $additionalParameters, string $expectation): void
67  {
68  $targetLanguageId = 0;
69  $this->‪mergeSiteConfiguration('acme-com', [
70  'routeEnhancers' => [
71  'Enhancer' => [
72  'type' => 'Extbase',
73  'routes' => [
74  ['routePath' => '/link/index/{value}', '_controller' => 'Link::index'],
75  ['routePath' => '/link/list/{value}', '_controller' => 'Link::list'],
76  ['routePath' => '/page/show/{value}', '_controller' => 'Page::show'],
77  ],
78  'defaultController' => 'Link::index',
79  'extension' => 'testing',
80  'plugin' => 'link',
81  'aspects' => [
82  'value' => [
83  'type' => 'StaticValueMapper',
84  'map' => [
85  'one' => 1,
86  ],
87  ],
88  ],
89  ],
90  ],
91  ]);
92 
93  $response = $this->executeFrontendSubRequest(
94  (new InternalRequest('https://acme.us/'))
95  ->withPageId(1100)
96  ->withInstructions([
98  'parameter' => 1100,
99  'language' => $targetLanguageId,
100  'additionalParams' => $additionalParameters,
101  'forceAbsoluteUrl' => 1,
102  ]),
103  ])
104  );
105 
106  self::assertSame($expectation, (string)$response->getBody());
107  }
108 
113  {
114  return [
115  '*::*' => [
116  '&tx_testing_link[value]=1',
117  'https://acme.us/welcome/link/index/one',
118  ],
119  '*::list' => [
120  '&tx_testing_link[action]=list&tx_testing_link[value]=1',
121  'https://acme.us/welcome/link/list/one',
122  ],
123  'Link::*' => [
124  // correctly falling back to defaultController here
125  '&tx_testing_link[controller]=Link&tx_testing_link[value]=1',
126  'https://acme.us/welcome/link/index/one',
127  ],
128  'Page::*' => [
129  // correctly falling back to defaultController here
130  '&tx_testing_link[controller]=Page&tx_testing_link[value]=1',
131  'https://acme.us/welcome/link/index/one',
132  ],
133  'Page::show' => [
134  '&tx_testing_link[controller]=Page&tx_testing_link[action]=show&tx_testing_link[value]=1',
135  'https://acme.us/welcome/page/show/one',
136  ],
137  ];
138  }
139 
148  public function ‪defaultExtbaseControllerActionNamesAreApplied(string $additionalParameters, string $expectation): void
149  {
150  $targetLanguageId = 0;
151  $this->‪mergeSiteConfiguration('acme-com', [
152  'routeEnhancers' => [
153  'Enhancer' => [
154  'type' => 'Extbase',
155  'routes' => [
156  ['routePath' => '/link/index/{value}', '_controller' => 'Link::index'],
157  ['routePath' => '/link/list/{value}', '_controller' => 'Link::list'],
158  ['routePath' => '/page/show/{value}', '_controller' => 'Page::show'],
159  ],
160  'defaultController' => 'Link::index',
161  'extension' => 'testing',
162  'plugin' => 'link',
163  'aspects' => [
164  'value' => [
165  'type' => 'StaticValueMapper',
166  'map' => [
167  'one' => 1,
168  ],
169  ],
170  ],
171  ],
172  ],
173  ]);
174 
175  $response = $this->executeFrontendSubRequest(
176  (new InternalRequest('https://acme.us/'))
177  ->withPageId(1100)
178  ->withInstructions([
180  'parameter' => 1100,
181  'language' => $targetLanguageId,
182  'additionalParams' => $additionalParameters,
183  'forceAbsoluteUrl' => 1,
184  ]),
185  ])
186  );
187 
188  self::assertSame($expectation, (string)$response->getBody());
189  }
190 }
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\EnhancerLinkGenerator\DefaultExtbaseControllerTest
Definition: DefaultExtbaseControllerTest.php:26
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\EnhancerLinkGenerator\AbstractEnhancerLinkGeneratorTestCase
Definition: AbstractEnhancerLinkGeneratorTestCase.php:33
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\EnhancerLinkGenerator\DefaultExtbaseControllerTest\defaultExtbaseControllerActionNamesAreAppliedWithAdditionalNonMappedQueryArgumentsDataProvider
‪array defaultExtbaseControllerActionNamesAreAppliedWithAdditionalNonMappedQueryArgumentsDataProvider()
Definition: DefaultExtbaseControllerTest.php:30
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\EnhancerLinkGenerator\DefaultExtbaseControllerTest\defaultExtbaseControllerActionNamesAreApplied
‪defaultExtbaseControllerActionNamesAreApplied(string $additionalParameters, string $expectation)
Definition: DefaultExtbaseControllerTest.php:148
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\EnhancerLinkGenerator\DefaultExtbaseControllerTest\defaultExtbaseControllerActionNamesAreAppliedDataProvider
‪array defaultExtbaseControllerActionNamesAreAppliedDataProvider()
Definition: DefaultExtbaseControllerTest.php:112
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\AbstractTestCase\createTypoLinkUrlInstruction
‪ArrayValueInstruction createTypoLinkUrlInstruction(array $typoScript)
Definition: AbstractTestCase.php:130
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\EnhancerLinkGenerator\DefaultExtbaseControllerTest\defaultExtbaseControllerActionNamesAreAppliedWithAdditionalNonMappedQueryArguments
‪defaultExtbaseControllerActionNamesAreAppliedWithAdditionalNonMappedQueryArguments(string $additionalParameters, string $expectation)
Definition: DefaultExtbaseControllerTest.php:66
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\mergeSiteConfiguration
‪mergeSiteConfiguration(string $identifier, array $overrides)
Definition: SiteBasedTestTrait.php:89