‪TYPO3CMS  11.5
RouteTest.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 
32 
37 {
39 
40  public function ‪routeDefaultsForSingleParameterAreConsideredDataProvider($parentSet = null): array
41  {
42  $builder = ‪Builder::create();
43  $enhancerDeclarations = $builder->declareEnhancers();
44  // variables (applied when invoking expectations)
45  $variables = ‪Variables::create()->define([
46  'routePrefix' => 'enhance',
47  'aspectName' => 'value',
48  ]);
49  return ‪Permutation::create($variables)
50  ->withTargets(
51  ‪TestSet::create($parentSet)
52  ->withMergedApplicables(‪LanguageContext::create(0))
53  ->withTargetPageId(1100)
54  ->withUrl(
56  'https://acme.us/welcome/enhance[[uriValue]][[pathSuffix]]',
57  ‪Variables::create(['pathSuffix' => '', 'uriValue' => '/hundred'])
58  )
59  ),
60  ‪TestSet::create($parentSet)
61  ->withMergedApplicables(‪LanguageContext::create(1))
62  ->withTargetPageId(1100)
63  ->withUrl(
65  'https://acme.fr/bienvenue/enhance[[uriValue]][[pathSuffix]]',
66  ‪Variables::create(['pathSuffix' => '', 'uriValue' => '/cent'])
67  )
68  )
69  )
70  ->withApplicableSet(
71  $enhancerDeclarations['Simple'],
72  // cannot use Plugin enhancer here - won't be used if no parameters for plugin namespace are given
73  // $enhancerDeclarations['Plugin']
74  // ->withConfiguration(['routePath' => $routePath], true),
75  $enhancerDeclarations['Extbase']
76  )
77  ->withApplicableSet(
78  ‪EnhancerDeclaration::create('defaults.value=100')->withConfiguration([
79  'defaults' => ['value' => 100],
80  ])
81  )
82  ->withApplicableSet(
83  ‪AspectDeclaration::create('StaticValueMapper')->withConfiguration([
84  ‪VariableItem::create('aspectName', [
85  'type' => 'StaticValueMapper',
86  'map' => [
87  'hundred' => 100,
88  ],
89  'localeMap' => [
90  [
91  'locale' => 'fr_FR',
92  'map' => [
93  'cent' => 100,
94  ],
95  ],
96  ],
97  ]),
98  ])
99  )
100  ->withApplicableSet(
102  'routeParameter' => '{value}',
103  'uriValue' => '',
104  ])),
106  'routeParameter' => '{!value}',
107  ]))
108  )
109  ->withApplicableSet(
111  'value' => null,
112  ])),
114  'value' => 100,
115  ]))
116  )
117  ->permute()
118  ->getTargetsForDataProvider();
119  }
120 
126  public function ‪routeDefaultsForSingleParameterAreConsidered(‪TestSet $testSet): void
127  {
128  $this->‪assertGeneratedUriEquals($testSet);
129  }
130 
131  public function ‪routeDefaultsForMultipleParametersAreConsideredDataProvider($parentSet = null): array
132  {
133  $builder = ‪Builder::create();
134  $routePath = ‪VariableValue::create('/[[routePrefix]]/[[routeParameter]]/{additional}');
135  $enhancerDeclarations = $builder->declareEnhancers();
136  // variables (applied when invoking expectations)
137  $variables = ‪Variables::create()->define([
138  'routePrefix' => 'enhance',
139  'aspectName' => 'value',
140  ]);
141  return ‪Permutation::create($variables)
142  ->withTargets(
143  ‪TestSet::create($parentSet)
144  ->withMergedApplicables(‪LanguageContext::create(0))
145  ->withTargetPageId(1100)
146  ->withUrl(
148  'https://acme.us/welcome/enhance/hundred/20[[pathSuffix]]?cHash=',
149  ‪Variables::create(['pathSuffix' => ''])
150  )
151  ),
152  ‪TestSet::create($parentSet)
153  ->withMergedApplicables(‪LanguageContext::create(1))
154  ->withTargetPageId(1100)
155  ->withUrl(
157  'https://acme.fr/bienvenue/enhance/cent/20[[pathSuffix]]?cHash=',
158  ‪Variables::create(['pathSuffix' => ''])
159  )
160  )
161  )
162  ->withApplicableSet(
163  $enhancerDeclarations['Simple']
164  ->withConfiguration(['routePath' => $routePath], true)
165  ->withGenerateParameters(['&additional=20'], true),
166  $enhancerDeclarations['Plugin']
167  ->withConfiguration(['routePath' => $routePath], true)
168  ->withGenerateParameters(['&testing[additional]=20'], true),
169  $enhancerDeclarations['Extbase']
170  ->withConfiguration(['routes' => [0 => ['routePath' => $routePath]]], true)
171  ->withGenerateParameters(['&tx_testing_link[additional]=20'], true)
172  )
173  ->withApplicableSet(
174  ‪EnhancerDeclaration::create('defaults.value=100')->withConfiguration([
175  'defaults' => ['value' => 100],
176  ])
177  )
178  ->withApplicableSet(
179  ‪AspectDeclaration::create('StaticValueMapper')->withConfiguration([
180  ‪VariableItem::create('aspectName', [
181  'type' => 'StaticValueMapper',
182  'map' => [
183  'hundred' => 100,
184  ],
185  'localeMap' => [
186  [
187  'locale' => 'fr_FR',
188  'map' => [
189  'cent' => 100,
190  ],
191  ],
192  ],
193  ]),
194  ])
195  )
196  ->withApplicableSet(
198  'routeParameter' => '{value}',
199  ])),
201  'routeParameter' => '{!value}',
202  ]))
203  )
204  ->withApplicableSet(
206  'value' => null,
207  ])),
209  'value' => 100,
210  ]))
211  )
212  ->permute()
213  ->getTargetsForDataProvider();
214  }
215 
221  public function ‪routeDefaultsForMultipleParametersAreConsidered(‪TestSet $testSet): void
222  {
223  $this->‪assertGeneratedUriEquals($testSet, false);
224  }
225 
226  public function ‪routeRequirementsHavingAspectsAreConsideredDataProvider($parentSet = null): array
227  {
228  $builder = ‪Builder::create();
229  // variables (applied when invoking expectations)
230  $variables = ‪Variables::create()->define([
231  'routePrefix' => 'enhance',
232  'aspectName' => 'value',
233  'inArguments' => 'staticArguments', // either 'dynamicArguments' or 'staticArguments'
234  ]);
235  return ‪Permutation::create($variables)
236  ->withTargets(
237  ‪TestSet::create($parentSet)
238  ->withMergedApplicables(‪LanguageContext::create(0))
239  ->withTargetPageId(1100)
240  ->withUrl(
242  'https://acme.us/welcome/enhance/[[resolveValue]][[pathSuffix]]',
243  ‪Variables::create(['pathSuffix' => ''])
244  )
245  )
246  )
247  ->withApplicableSet(
249  'value' => 100,
250  'resolveValue' => 'hundred',
251  ])),
253  'value' => 1100100,
254  'resolveValue' => 'hundred/binary',
255  ])),
258  'value' => 100,
259  'resolveValue' => 'hundred',
260  ])),
261  ‪EnhancerDeclaration::create('requirements.value=/[a-z_/]+/')->withConfiguration([
262  'requirements' => [
263  'value' => '[a-z_/]+',
264  ],
265  ])
266  ),
269  'value' => 1100100,
270  'resolveValue' => 'hundred/binary',
271  ])),
272  ‪EnhancerDeclaration::create('requirements.value=/[a-z_/]+/')->withConfiguration([
273  'requirements' => [
274  'value' => '[a-z_/]+',
275  ],
276  ])
277  )
278  )
279  ->withApplicableItems($builder->declareEnhancers())
280  ->withApplicableSet(
281  ‪AspectDeclaration::create('StaticValueMapper')->withConfiguration([
282  ‪VariableItem::create('aspectName', [
283  'type' => 'StaticValueMapper',
284  'map' => [
285  'hundred' => 100,
286  'hundred/binary' => 1100100,
287  ],
288  ]),
289  ])
290  )
291  ->permute()
292  ->getTargetsForDataProvider();
293  }
294 
300  public function ‪routeRequirementsHavingAspectsAreConsidered(‪TestSet $testSet): void
301  {
302  $this->‪assertGeneratedUriEquals($testSet);
303  }
304 
310  public function ‪nestedRouteArgumentsAreConsidered(‪TestSet $testSet): void
311  {
312  $this->‪assertGeneratedUriEquals($testSet);
313  }
314 }
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\EnhancerLinkGenerator\AbstractEnhancerLinkGeneratorTestCase\assertGeneratedUriEquals
‪assertGeneratedUriEquals(TestSet $testSet, bool $strict=true)
Definition: AbstractEnhancerLinkGeneratorTestCase.php:139
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\Permutation
Definition: Permutation.php:23
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\VariableItem\create
‪static create(string $key, $value)
Definition: VariableItem.php:31
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\EnhancerLinkGenerator\AbstractEnhancerLinkGeneratorTestCase
Definition: AbstractEnhancerLinkGeneratorTestCase.php:33
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\TestSetDataProviderTrait
Definition: TestSetDataProviderTrait.php:33
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\AspectDeclaration\create
‪static create(string $identifier)
Definition: AspectDeclaration.php:25
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\ApplicableConjunction\create
‪static create(Applicable ... $applicables)
Definition: ApplicableConjunction.php:27
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\Variables
Definition: Variables.php:21
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\VariablesContext\create
‪static create(Variables $variables)
Definition: VariablesContext.php:29
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\VariablesContext
Definition: VariablesContext.php:21
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\Permutation\create
‪static create(Variables $variables)
Definition: Permutation.php:44
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\TestSet
Definition: TestSet.php:21
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\Builder
Definition: Builder.php:21
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\Builder\create
‪static create()
Definition: Builder.php:22
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\VariableValue\create
‪static create(string $value, Variables $defaultVariables=null)
Definition: VariableValue.php:43
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\Variables\create
‪static create(array $items=[])
Definition: Variables.php:22
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\EnhancerDeclaration\create
‪static create(string $identifier)
Definition: EnhancerDeclaration.php:27
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\AspectDeclaration
Definition: AspectDeclaration.php:21
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\VariableItem
Definition: VariableItem.php:21
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\LanguageContext
Definition: LanguageContext.php:21
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\ApplicableConjunction
Definition: ApplicableConjunction.php:21
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\VariableValue
Definition: VariableValue.php:21
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\EnhancerDeclaration
Definition: EnhancerDeclaration.php:21
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\TestSet\create
‪static create($parentSet=null)
Definition: TestSet.php:42
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\LanguageContext\create
‪static create(int $languageId)
Definition: LanguageContext.php:24